How do I extract non sequential rows of a matrix without using a for loop?
2 次查看(过去 30 天)
显示 更早的评论
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".
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!