Reputation: 6835
Is there a way in MATLAB to select from a matrix with a range of values in column A(:,1)
where:
B
= select from A
where A(:,1)<20070000
Cannot find this logic anywhere
EDIT: I need to select these indicated rows from all columns of A
.
Upvotes: 0
Views: 1085
Reputation: 30579
A straightforward solution looks like this:
rowInds = find(A(:,1)<2007000);
B = A(rowInds,:);
This will have the same number of columns as A
. As Dan said it works without the find
, using just the logical array to specify the rows directly. Either way is fine.
The question has been clarified to requiring all columns, so the above is sufficient.
Upvotes: 1
Reputation: 45752
Actually to get all the rows can just do this:
B = A(A(:,1)<20070000,:)
Upvotes: 1