## find a row with -1

on 7 Jun 2013

### Andrei Bobrov (view profile)

A=[-1,1,1;0,-1,0;0,0,-1;1,0,0];

blnA = logical( A == -1 );

blnOut = find( sum( blnA' ) == 1 );

With that command

blnOut =

`     1     2     3`

I have to find row which include only one -1 or other element in row must be 0 not 1. In that matrix, row including 1 is found too.

So 2nd row must be chosen.

Thank you

## Products

No products are associated with this question.

### Andrei Bobrov (view profile)

on 7 Jun 2013
Edited by Andrei Bobrov

### Andrei Bobrov (view profile)

on 7 Jun 2013

```blnOut = find(all(ismember(A,[0,-1]),2));
```

Andrei Bobrov

on 7 Jun 2013

corrected

Light

### Light (view profile)

on 7 Jun 2013

Same result. blnOut =

```     1
2
3```

Must be the

blnOut=

2

3

i have to find row which including only -1. row 1 is including 1.

Walter Roberson

### Walter Roberson (view profile)

on 7 Jun 2013

#### Join the 15-year community celebration.

Play games and win prizes!

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi