operators must be convertible to logical scalar values

조회 수: 3 (최근 30일)
Riccardo Tronconi
Riccardo Tronconi 2021년 7월 21일
답변: Walter Roberson 2021년 7월 21일
Dear guys! I'm struggling to solve this dummy issue. Here it is my code:
if Inan> Istart && (Inan<Iend || isempty(Iend)==1)
Iend=Inan - 1;
end
the error is : Operands to the logical and (&&) and or (||) operators must be convertible to logical scalar values.
Thanks in advance!

채택된 답변

Walter Roberson
Walter Roberson 2021년 7월 21일
If Iend is empty then Inan<Iend is empty and you would be trying to use (empty || something) but operands for || must be scalars.
You should test for empty before testing <
Note: you can use just isempty(Iend) instead of isempty(Iend)==1

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by