MATLAB: Is there a compact way to check multiple variables against the same conditions

MATLAB

I'm thinking about how to make some code I'm working on easier to read. For example, if I have something like the following:
if x != 0 && y != 0 && z != 0
% stuff

end
Is there a way for me to turn that into something more compact, like:
if (x&y&z) != 0
% stuff
end
Or do I just have to put up with this? This may not look like an ugly example, but there are some ugly lines I have which involve comparing a number of variables against the same set of parameters. I've considered setting up a function to which I can pass an array of variables and a set of conditions to check them against, but I'd prefer a syntax-related solution. Thanks in advance.

Best Answer

If x, y, z are logical, then you can write the logical expression as above; if they're numeric and can hold anything but 0|1 then you have to do the explicit logic test to convert to a logical condition.
BTW, NB: if they're vectors or arrays, then be awfully careful of the && shortcircuit operators and remember that in Matlab an expression is TRUE iff
all(x)==true
Many a poster has wondered why their if clause doesn't seem to get executed owing to the latter.