How to get rid of Warning"Unexpected use of '[' in a scalar context."
41 次查看(过去 30 天)
显示 更早的评论
a part of the function has:
if the input A (a vector) matches what is stated, the statement runs.
if A == [1,3,3]
% statement
end
and it gives me this error: 'Unexpected use of '[' in a scalar context. How can I fix this?
3 个评论
采纳的回答
更多回答(1 个)
KSSV
2018-8-13
When you use A == [1 3 3] ;
With this operator ==, MATLAB expects a scalar value, but the way used here, it gives array as output. So the warning pops out. The way you use, won't work out. YOu need to use the operator == with a scalar value, so the if condition works fine.
5 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scope Variables and Generate Names 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!