Delete multiple rows from array
Mostrar comentarios más antiguos
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 comentarios
the cyclist
el 27 de Feb. de 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
el 27 de Feb. de 2012
might want to look at ismember() to build up your index2delete vector
Respuesta aceptada
Más respuestas (1)
prasoon purwar
el 27 de Feb. de 2012
if isequal(v3,0)==1
array(n,:)=[]
end % array is your matrix
% n is the row , which is to be removed
1 comentario
Matt
el 27 de Feb. de 2012
Categorías
Más información sobre Data Type Identification en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!