MATLAB: Determine all cells are non-zero within a matrix

MATLABmatrixnon-zero

I am trying to determine if all of the numbers in "x" is non-zero values:
x = [1 1 0]
% 1:
if x ~= [0 0 0]
disp('x is not zeros')
end
% 2:
if all(x ~= 0)
disp('x is not zeros')
end
but the output is saying the x is zeros.
what mistake did I make?

Best Answer

  • Your second if statement is correct, and I get the correct output (none).