Delete multiple rows from array
Ältere Kommentare anzeigen
I need to delete multiple rows from an array. I know I cannot use a loop because the size of the array will change.
Does anyone have any suggestions on how to accomplish this?
UPDATED: For example, if I have an array such as:
1 9 0
2 1 2
5 8 3
7 1 0
Depending on if the 3rd column is a 0 (I used num2cell, so I'm not sure what type that makes each item in the cells), then I want to delete the whole row. So in the above example,
1 9 0
7 1 0
Would both be deleted, and the array would then only be a 2x3 array.
Thanks in advance! Let me know if I need to add more details. -Matt
2 Kommentare
the cyclist
am 27 Feb. 2012
Could you give more detail on what your array looks like (or, ideally, a small example)? Is "array" really a cell array, as the comment suggests? If so, then it seems that v1,v2 and v3 are also cell arrays. If that's the case, then what's inside the cells?
Sean de Wolski
am 27 Feb. 2012
might want to look at ismember() to build up your index2delete vector
Akzeptierte Antwort
Weitere Antworten (1)
prasoon purwar
am 27 Feb. 2012
if isequal(v3,0)==1
array(n,:)=[]
end % array is your matrix
% n is the row , which is to be removed
1 Kommentar
Matt
am 27 Feb. 2012
Kategorien
Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!