Reputation: 57
I am studying skeletal co-ordinates and so far I have three joints with their x,y and z coordinates in a single matrice X. X is currently 214 x 9. In X, should be certain coordinates that match conditions I am investigating.
I want to be able to search each column using specific criteria, for example, column 1 (my x1 co-ordinate) must be > 0.1227 but < 0.120781. column 2 must be also fit within certain criteria and so forth.
At the moment my code looks like something like this,
R = X(X< 0.122781 & X > 0.120781);
which obviously is not working. When I try to introduce (:,1) in this code (for column 1) I don't get anywhere either. I haven't found much information on this but maybe I am missing something.
Does anyone have any suggestions?
Upvotes: 0
Views: 73
Reputation: 114786
You need to select the appropriate rows, then index X
. You can do it as a "one-liner" but that might be difficult to read.
# example selecting according to first and second columns
row_sel = X(:,1) > 0.122 & X(:,1) < 0.2 & \
X(:,2) > 0.43 & X(:,2) < 0.5 ; %// and so on...
R = X(row_sel,:); %// select the matching rows.
Upvotes: 1