Thread Subject: Deleting rows

Subject: Deleting rows

From: Diego Zegarra

Date: 21 Feb, 2009 18:50:04

Message: 1 of 2

Assume we have a matrix,

a =[8 3;9 3;7 2;4 2;5 1;10 1]

After some operations a(:,2)=a(:,2)-1 and when there are numbers in the second column equal to 0, I wish to delete the complete row. Is there a faster way to do it than the following?

Now a = [8 2;9 2;7 1;4 1;5 0;10 0]

b=find(a(:,2)==0);
a(b,:)=[];

Thanks!

Subject: Deleting rows

From: Matt Fig

Date: 21 Feb, 2009 19:30:05

Message: 2 of 2

You don't need the find function for this:
a(a(:,2)==0,:)=[];





7fmd^`^evkll|^q+_ksihJ|^|ll$qj^bl$B_^b||bmefqrr|ji^e`V=||lb

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com