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

m-file

0 Comments

mayuresh

mayuresh (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson

Walter Roberson (view profile)

on 25 Jul 2012

See http://www.mathworks.com/help/techdoc/ref/lt.html and http://www.mathworks.com/help/techdoc/ref/gt.html

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.

0 Comments

Walter Roberson

Walter Roberson (view profile)

Contact us