Matlab matrix ones elements checking -


suppose have vector x = [1 1 1 1 1 1].

now have write if condition, have check whether x contains elements ones or not. how can done?

i searched in matlab's help, couldn't find direct "command" check such condition. size of vector varies, can't use x(1,1) == 1 && x(2,1) ..... condition.

all(x == 1) return 1 if members 1.

if you'd rather check reverse, use any(x ~= 1).


Comments