How do I find multiple columns greater than a single column in MATLAB? -
i have single column vector average of other multiple columns (in vector). wish index when each element of matrix is greater average vector. able 1 @ time with:
idx = y1<y2
however if y2
matrix comes error. current solution on come is:
y1 = [y1;y1]
but rather inelegant , doesn't business relationship y2
's of unknown sizes. regards
i think looking -
idx = bsxfun(@lt,y1,y2)
this create logical array of same size input matrix y2
1
's elements in y2
greater than
corresponding elements in y1
, 0
's otherwise.
best thing bsxfun
solve such problem takes care of expansion
needed. so, have generic solution without querying sizes
.
matlab
No comments:
Post a Comment