How to extract specific row data from a big matrix?
Show older comments
Here are my data [1 5; 1 1; 1 2; 1 3; 1 1; 2 2; 2 2; 2 1; 2 3; 2 1] . Now, I want to extract the rows which have either 1 1, 1 2 , 2 1, or 2 2 and export it as a new data file. Any pointers on how to achieve this? I am able to extract by just one row value. For example, with the below code I get all the data that has 2 in the column 1. However, I do not know how to include both columns for all the above-mentioned cases i.e. 1 1, 1 2, 2 1, 2 2.
Code: data=[1 5; 1 1; 1 2; 1 3; 1 1; 2 2; 2 2; 2 1; 2 3; 2 1]; temp=data(data(:,1)==2,:);
Output: temp =
2 2
2 2
2 1
2 3
2 1
Accepted Answer
More Answers (0)
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!