Error: Operands to the || and && operators must be convertible to logical scalar values.
조회 수: 1 (최근 30일)
이전 댓글 표시
I need to say:
if ((YesNo=='Yes') ||(YesNo=='yes'))
if YesNo was 'Yes' or 'yes' then do sth. but I recieve error shown in the title.
댓글 수: 0
답변 (1개)
Fangjun Jiang
2020년 1월 14일
use strcmpi()
댓글 수: 2
Fangjun Jiang
2020년 1월 14일
편집: Fangjun Jiang
2020년 1월 14일
YesNo=='Yes' returns a 1x3 array, or a vector
"||" can only be applied to logical scalar values
you could use (YesNo=='Yes') | (YesNo=='yes'), or call the or() function, or(YesNo=='Yes', YesNo=='yes'), but that still returns a vector.
help relop
참고 항목
카테고리
Help Center 및 File Exchange에서 Install Products에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!