Index in Position 2 is invalid.
Ältere Kommentare anzeigen
X=[200:2000]
for i = 1:1801
A = X(1,i)/2
B(1,i)= A
end
i=0
while i<1801
if i==750
break
elseif mod(i,2)==1
C(1,i)=B(1,i)*2
elseif mod(i,2)==0
C(1,i)=B(1,i)/2 %Index in Position 2 is invalid.
end
i=i+1
end
The programm works only without the second elseif. If I add the second elseif, I get the error: "Index in Position 2 is invalid." Can someone help?
Akzeptierte Antwort
Weitere Antworten (1)
Francesco Torricelli
am 8 Mai 2020
0 Stimmen
Hi,
you can easily solve your issue by setting i = 1 just before the while loop (i = 0 leads to the error you encountered in the very first iteration).
1 Kommentar
captainjoker
am 8 Mai 2020
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!