Non-scalars are not supported in IF or WHILE statements

1 view (last 30 days)
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....

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 3 May 2014
Edited: Azzi Abdelmalek on 3 May 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)

More Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!