Strange behaviour with elseif
Ältere Kommentare anzeigen
Hi, I noticed something totally strange with a repeated elseif statement. Here is the code:
A = [0.0001:0.0001:0.0009];
for i=1:length(A)
x=A(i);
if x == 0.0001
x
elseif x == 0.0002
x
elseif x == 0.0003
x
elseif x == 0.0004
x
elseif x == 0.0005
x
elseif x == 0.0006
x
elseif x == 0.0007
x
elseif x == 0.0008
x
elseif x == 0.0009
x
else
display('Error')
end
end
When I run it, I get twice the "Error" displayed, for x=0.0003 and x=0.0008. I could reproduce it on two different Matlab version (R2009a & R2010a). Any idea? Thanks a lot.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Scope Variables and Generate Names finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!