Hi,
When I type the following code:
if size([1 2 3])==size([4 5 6]) & size([4 5 6])==size([7 8 9])
'yes'
else
'no'
end
MATLAB Code Analyzer issues this warning message: "When both arguments are numeric scalars, consider replacing & with && for performance."
So, I use && instead of &:
if size([1 2 3])==size([4 5 6]) && size([4 5 6])==size([7 8 9])
'yes'
else
'no'
end
But when I run the updated script, MATLAB displays an error message in the Command Window:
??? Operands to the || and && operators must be convertible to logical scalar values.
What can I do to fix this? Thanks in advance.
Andrew DeYoung
Carnegie Mellon University
7 件のコメント
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_14941
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_14941
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_14942
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_14942
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_14965
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_14965
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_14976
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_14976
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_14978
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_14978
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_15066
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_15066
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_383021
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/7164-using-and-operator-in-if-statements#comment_383021
サインインしてコメントする。