How to solve && operands to logical scalar
问题 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 回答1: If dIx and dIy are matrices (as opposed to 1-D vectors), max(dIx) and max(dIy) will return vectors. && and ||