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?

what dos this instruction mean

Asked by billel madridi

billel madridi (view profile)

on 16 May 2013

i meet this instruction when analyzing a matlab file could you help me what does it mean ?

yone=(y==i)+(y~=i)*-1;

when y is a column vector and i is fix number i=4;

what will be the size of yone in this case ?

0 Comments

billel madridi

billel madridi (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson

Walter Roberson (view profile)

on 16 May 2013

A value of "1" where the entries are "i", and a value of "-1" where the entries are not "i", and 0 where the entries are NaN.

1 Comment

Jan Simon

Jan Simon (view profile)

on 16 May 2013

Equivalent:

yone = 2 * (y==i) - 1;
Walter Roberson

Walter Roberson (view profile)

Contact us