How can i find "AND" or "OR" of rows in a matrix?

Hi friends,
I'm actually working on a matrix and i need to apply "and" logic operation on the rows. For example, if we have Matrix A with 3 rows and 10 columns, i want to find the Matrix B with size 1*10 which has the result of the operation (Row1) & (Row2) & (Row3).

Answers (1)

A = round(rand(3,10))
all(A) % A(1,:) & A(2,:) & A(3,:)
any(A) % A(1,:) | A(2,:) | A(3,:)

This question is closed.

Asked:

on 14 May 2011

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!