How do I extract non sequential rows of a matrix without using a for loop?
2 views (last 30 days)
Show older comments
I have a very large matrix (m1), and I want to create a new matrix (m2) using certain rows of m1. The list of rows I want is contained in a 1xN matrix called "list". Naively, I would expect the command to be
m2 = [m1(list,:)]
However, matlab will not accept a matrix as an index. (I receive the error "Subscript indices must either be real positive integers or logicals.")
Any help would be appreciated.
For context: The matrix m1 is too large for me to attempt this exercise by hand -- it contains 100000 rows. Also, there is no obvious mathematical relationship among the entries in "list".
3 Comments
Answers (0)
See Also
Categories
Find more on Multidimensional Arrays 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!