# logical operators on a logical matrix

40 views (last 30 days)
Pankaj on 13 Sep 2019
Commented: Pankaj on 13 Sep 2019
Consider the following logical matrix of 4X2
A = logical([1, 0; 1, 1; 0, 0; 0, 1])
I would like to apply logical operator (say `or`, `and`) on the matrix row wise so the result is 4X1 vector. (the matrix could of any dimension say mXn, and I want mX1 as output). The `or` operator requires two matrices for comparision, how to do it for single matrix.
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Accepted Answer

madhan ravi on 13 Sep 2019
all(A,2)
any(A,2)
##### 4 CommentsShow 2 older commentsHide 2 older comments
madhan ravi on 13 Sep 2019
Thanks Jos :)
Pankaj on 13 Sep 2019
thanks Jos

Sign in to comment.

### Categories

Find more on Creating and Concatenating 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!