How do you extract certain rows from one matrix thats first column has specific values and create a new matrix containing those rows?
3 views (last 30 days)
Show older comments
Jordan Terrazas
on 19 Mar 2017
Commented: JESUS DAVID ARIZA ROYETH
on 20 Mar 2017
I have a 126120,5 matrix. The first column has values of time. I want to create a new matrix that consists only of the rows that have time increments of 0.01 seconds from the original matrix (0.00s, 0.01s, 0.02s, 0.03s...). How can I go about doing so?
For example: M =
[0.00023 1 2 3 4 5]
[0.007 1 2 3 4 5]
[0.01 1 2 3 4 5]
[0.0127 1 2 3 4 5]
[0.02 1 2 3 4 5]
[0.0245 1 2 3 4 5]
[0.03 1 2 3 4 5]
Mnew =
[0.01 1 2 3 4 5]
[0.02 1 2 3 4 5]
[0.03 1 2 3 4 5]
I know of the command Mnew = M(M(:,1)==0.01,:);
but that is only one row and I don't want to have to do that over and over for each time. Any help would be much appreciated, Thank You!
0 Comments
Accepted Answer
JESUS DAVID ARIZA ROYETH
on 20 Mar 2017
You can use the function "mod"
M =[0.00023 1 2 3 4 5;
0.007 1 2 3 4 5;
0.01 1 2 3 4 5;
0.0127 1 2 3 4 5
0.02 1 2 3 4 5
0.0245 1 2 3 4 5
0.03 1 2 3 4 5];
Mnew=M(mod(M(:,1),0.01)==0,:);
2 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!