How to delete rows while maintaining the indexes?
Show older comments
I'm trying to represent a tree of arrays in a matrix, like this: m(2,:) and m(3,:) are the children of m(1,:), m(4,:) and m(5,:) are the children of m(2,:) and so on.
Now I want to delete some rows from the memory, while maintaining the indexes. For example: I have a matrix m=[1 2 3; 2 4 6; 3 6 9] and I want to delete row 2, so the result is: m=[1 2 3; ; 3 6 9].
Yes, I want the deleted row to count, because I have a lot of indexes pointing to the other rows, but not to consume memory.
I tried m(2,:)=[], but this way I lost the indexe. I mean, row 3 became row 2. Any ideas?
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!