Is possible select specific rows with all column in a loop?
5 views (last 30 days)
Show older comments
Orlando Ramirez-Valle
on 13 Jun 2021
Answered: Walter Roberson
on 14 Jun 2021
Hello.
I have a data matrix like the following
1 -5.01E-01 0.00E + 00
1.0865 1.09E-01 0.00E + 00
1.173 1.09E-01 0.00E + 00
1.2911 1.09E-01 0.00E + 00
1.4329 1.09E-01 0.00E + 00
1.6219 1.09E-01 0.00E + 00
1.811 1.09E-01 0.00E + 00
2 1.09E-01 0.00E + 00
2.3333 1.38E-01 0.00E + 00
2.6667 1.38E-01 0.00E + 00
3 1.38E-01 0.00E + 00
3.001 -2.15E-02 0.00E + 00
3.0023 -2.15E-02 0.00E + 00
3.004 -2.15E-02 0.00E + 00
3.0062 -2.15E-02 0.00E + 00
3.009 -2.15E-02 0.00E + 00
3.0128 -2.15E-02 0.00E + 00
3.0176 -2.15E-02 0.00E + 00
3.0239 -2.15E-02 0.00E + 00
3.032 -2.15E-02 0.00E + 00
3.0426 -2.15E-02 0.00E + 00
3.0564 -2.15E-02 0.00E + 00
3.0743 -2.15E-02 0.00E + 00
3.0976 -2.15E-02 0.00E + 00
3.1279 -2.15E-02 0.00E + 00
3.1673 -2.15E-02 0.00E + 00
3.2185 -2.15E-02 0.00E + 00
3,285 -2.15E-02 0.00E + 00
3.3744 -2.15E-02 0.00E + 00
3.4787 -2.15E-02 0.00E + 00
3.609 -2.15E-02 0.00E + 00
3.8045 -2.15E-02 0.00E + 00
4 -2.15E-02 0.00E + 00
4.25 1.55E-02 0.00E + 00
4.625 1.55E-02 0.00E + 00
5 1.55E-02 0.00E + 00
5.5 5.26E-02 0.00E + 00
6 5.26E-02 0.00E + 00
for this example how to get the integer values of column one (1, 2, 3, 4, 5 and 6) with all its columns.
Could it be done automatically? since I have a big matrix
I will really appreciate your valuable help.
Orlando
0 Comments
Accepted Answer
Walter Roberson
on 14 Jun 2021
mask = ismembertol(YourArray, 1:6);
selected_rows = YourArray(mask,:);
G = round(selected_rows(:,1));
split_groups = splitapply(@(M){M}, selected_rows, G)
0 Comments
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices 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!