Thread Subject: I need to find the row which has elements zero '0' and greater than 7 and eliminate that row

Subject: I need to find the row which has elements zero '0' and greater than 7 and eliminate that row

From: Joe Frank

Date: 18 Mar, 2009 21:02:01

Message: 1 of 5

I have a matrix

         1 2 7
A= 4 5 6
         1 2 3

I need to find the row which has elements zero '0' and greater than 7 and eliminate that row.

I wrote this piece of code but its not working. Please help me.

function A = properList(A)
[row len] = size(A);
if (A(1,1) == 0)
    A = A(2,:);
    for i=1:len
 if (A(1,i) > 6)
         A = A(2,:);
    else
         A = A(1,:);
     end
end
end

Thanks,
Joe

Subject: I need to find the row which has elements zero '0' and greater than 7 and eliminate that row

From: Matt Fig

Date: 18 Mar, 2009 23:12:01

Message: 2 of 5

"Joe Frank" <sascod@gmail.com> wrote in message
> I have a matrix
>
> 1 2 7
> A= 4 5 6
> 1 2 3
>
> I need to find the row which has elements zero '0' and greater than 7 and eliminate that row.




Your requirement is not comprehensible. In plain, understandable English, is this what you mean?

Find the rows of matrix A which have no zeros and at least one element greater than seven. Eliminate all such rows.

For example, it looks like the matrix you have shown will remain unchanged.




EKDbbYLNEHXHDWO<RSbDQDR|bPWKSRiW#iHF(O\Q0KDbbFpRbRDLbRJPDXH

Subject: I need to find the row which has elements zero '0' and greater than 7 and eliminate that row

From: Joe Frank

Date: 19 Mar, 2009 00:07:01

Message: 3 of 5

"Matt Fig" <spamanon@yahoo.com> wrote in message <gprv41$qrt$1@fred.mathworks.com>...
> "Joe Frank" <sascod@gmail.com> wrote in message
> > I have a matrix
> >
> > 1 2 7
> > A= 4 5 6
> > 1 2 3
> >
> > I need to find the row which has elements zero '0' and greater than 7 and eliminate that row.
>
>
>
>
> Your requirement is not comprehensible. In plain, understandable English, is this what you mean?
>
> Find the rows of matrix A which have no zeros and at least one element greater than seven. Eliminate all such rows.
>
> For example, it looks like the matrix you have shown will remain unchanged.
>
>
>
>
> EKDbbYLNEHXHDWO<RSbDQDR|bPWKSRiW#iHF(O\Q0KDbbFpRbRDLbRJPDXH

I am sorry for the confusion. I need to check the first row of matrix 'A' if it contains either '0' or any number greater than '7' and if it contains them then we have to remove that row from the matrix.

Thanks

Subject: I need to find the row which has elements zero '0' and greater than 7 and eliminate that row

From: Matt Fig

Date: 19 Mar, 2009 00:21:02

Message: 4 of 5

Well a straightforward approach would be to use a simple If statement.

if any(A(1,:)==0 | A(1,:)>7)
   A = A(2:end,:)
end

Subject: I need to find the row which has elements zero '0' and greater than 7 and eliminate that row

From: Joe Frank

Date: 19 Mar, 2009 14:05:04

Message: 5 of 5

"Matt Fig" <spamanon@yahoo.com> wrote in message <gps35e$8bo$1@fred.mathworks.com>...
> Well a straightforward approach would be to use a simple If statement.
>
> if any(A(1,:)==0 | A(1,:)>7)
> A = A(2:end,:)
> end

Thanks

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