if clause for a nonscalar operator

2 Ansichten (letzte 30 Tage)
shirin mhd
shirin mhd am 2 Aug. 2022
Kommentiert: Abderrahim. B am 2 Aug. 2022
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???

Akzeptierte Antwort

Abderrahim. B
Abderrahim. B am 2 Aug. 2022
If I understood correctly:
p=[];
if ~isscalar(p)
disp('hello')
else
disp('bye')
end
hello
  2 Kommentare
shirin mhd
shirin mhd am 2 Aug. 2022
Thank you so much.
Abderrahim. B
Abderrahim. B am 2 Aug. 2022
My pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by