if clause for a nonscalar operator

3 次查看(过去 30 天)
Hi everyone
I have this code:
p=[];
if p==[]
disp('hello')
else
disp('bye')
end
and I expect this answer:
>> test
hello
but I receive this answer:
>> test
bye
how can i solve this problem???

采纳的回答

Abderrahim. B
Abderrahim. B 2022-8-2
If I understood correctly:
p=[];
if ~isscalar(p)
disp('hello')
else
disp('bye')
end
hello

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by