matlab - Relational operator and array index -


x=[15 -8 15 4];   y=[-3 8 13 4];  z=y(x>y)  z =     -3    13 

it seems i'm getting confused array index concept.
please explain output.

to understand try looking @ intermediate output of each step of operation.

x=[15 -8 15 4];
y=[-3 8 13 4];
result1 = x > y
result1 = [1 0 1 0]
z = y([1 0 1 0])
z = [-3 13]

the comparison x > y returns logical array applied y pull out elements @ non-zero values. different array indexing access array element index value, e.g. y(3).


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -