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!