如何解决&&逻辑标量的操作数 [英] How to solve && operands to logical scalar
本文介绍了如何解决&&逻辑标量的操作数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在matlab中运行代码后,我遇到了这个错误并且不确定如何解决它。我该如何解决这个问题。
After I run the code in matlab, I encounter this error and unsure how to solve it. How can I solve this problem.
警告:
Warning:
操作数到| |和&&运算符必须可转换为逻辑标量值。
Operands to the || and && operators must be convertible to logical scalar values.
Jgray = double(rgb2gray(J));
% Calculate the Gradients
[dIx, dIy] = gradient(Jgray);
if max(dIx)<=103 && max(dIy)<=100
B = abs(dIy) - abs(dIx);
else
B = abs(dIx) - abs(dIy);
end
推荐答案
如果dIx和dIy是矩阵(与1-D向量相反), max(dIx)
和 max(dIy)
将返回向量。
If dIx and dIy are matrices (as opposed to 1-D vectors), max(dIx)
and max(dIy)
will return vectors.
&&
和 ||
应该是用来比较标量,而不是矢量。
&&
and ||
should be used to compare scalars, not vectors.
您可能想要输入
if max(dIx(:))<=103 && max(dIy(:))<=100
但我无法确定,因为我不知道代码应该做什么:)
but I cannot tell for sure, as I dont know what the code is supposed to do :)
这篇关于如何解决&&逻辑标量的操作数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文