Non-scalars are not supported in IF or WHILE statements

3 Ansichten (letzte 30 Tage)
if true
[min_bb,idxb]=min(errorb(:,:,ii));
[linebb,codexbb]=ind2sub(size(errorb),idxb); %find minumum location per_phase
end
this my code, I am trying to use "codexbb" and "linebb" in IF statement like
if(linebb==2)
but, matlab gives an erros and said "Non-scalars are not supported in IF or WHILE statements". On the other way, when I checked its dimensions, it says 1 1. How can I solve the problem ?
King Regard....

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 3 Mai 2014
Bearbeitet: Azzi Abdelmalek am 3 Mai 2014
linebb is a vector, what do you want to test? for example if
linebb=[1 2 3]
your are trying to compare linebb to 2,
linebb==2
the result is
0 1 0
you have to explain what you want, if you want to test if 2 belong to linebb you can do it by
ismember(2,linebb)

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by