Reputation: 329
My matrix has 10 columns. I want to select all rows where the first column is less than 4. If I use
data(data(:,1)<4)
Only the first column is selected.
How do I display all corresponding column values?
How do I select a single corresponding column, e.g., select column 2 where value of column1<4?
Upvotes: 0
Views: 575
Reputation: 29104
data(data(:,1)<4,:)
: indicates all columns. Since data is 2-d matrix, you need to input two parameters, one for row and one for column.
If you need specific columns like column 2
data(data(:,1)<4,2)
Upvotes: 2