searching for elements and deleting them in an array

1 view (last 30 days)
Hi ! I have the next array:
the mission is for matlab locate all the rows with non real compenents or zeros and delete their respective rows
for example in the above array, rows: 1,2,3,6,7,8,9 should be deleted. thanks!(im using matlab R2007b)
  1 Comment
Stephen23
Stephen23 on 1 Jun 2015
Edited: Stephen23 on 1 Jun 2015
It is much easier for everyone else if you insert your data as text, and not as an image, then we do not need to type it all in again. Code should be formatted using the {} Code button that you will find above the textbox.

Sign in to comment.

Answers (1)

dpb
dpb on 31 May 2015
ix=any(imag(x)~=0 | x==0,2);
x(ix,:)=[];
You can, of course, combine the logical expression into the subscript and thus eliminate the temporary.

Categories

Find more on Shifting and Sorting Matrices 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!