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 use the compare signal in m-file (>/<)

Asked by mayuresh

mayuresh (view profile)

on 25 Jul 2012




mayuresh (view profile)


No products are associated with this question.

1 Answer

Answer by Walter Roberson

Walter Roberson (view profile)

on 25 Jul 2012

See and

If you are comparing vectors or arrays, please be sure to note this behavior of if

An evaluated expression is true when the result is nonempty and contains all nonzero elements (logical or real numeric). Otherwise, the expression is false.

So when you have

if A < B

and A or B is a vector (or a matrix) then the "if" is only considered true if all A < B are true.


Walter Roberson

Walter Roberson (view profile)

Contact us