How to check in MATLAB if a vector only contains zeros?
matlab
Solution
Use `all`:
vector = zeros(1,10)
if 1 && all(vector == 0) %this comparision will work
'success'
end
Problem
What is the "MATLAB-way" to check if a vector only contains zeros, so that it will be evaluated to a scalar rather than to a vector. If I run this code: ``` vector = zeros(1,10) %the "1" represents a function that returns a scalar if 1 && vector == 0 %this comparision won't work 'success' end ``` I get the error: ??? Operands to the || and && operators must be convertible to logical scalar values.