Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

How to apply OR operation to a matrix?

Asked by pietro

pietro (view profile)

on 12 Jul 2014
Latest activity Answered by Roger Stafford

Roger Stafford (view profile)

on 12 Jul 2014

Hi folk,

I need to apply the OR operation to the column of a matrix. Here an example:

a=[0 0 1; 0 1 1];
orMat(a)=
[0 0 1]

thanks

0 Comments

pietro

pietro (view profile)

Products

1 Answer

Answer by Roger Stafford

Roger Stafford (view profile)

on 12 Jul 2014
Accepted answer

Your example is not the 'OR', it is the 'AND', of the columns. The 'OR' of the columns is done this way:

 b = any(a,1);

The 'AND' would be done this way:

 b = all(a,1);

0 Comments

Roger Stafford

Roger Stafford (view profile)

Contact us