Index exceeds the number of array elements (6).
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I get this error and do not solve the problem please inform me how to solve it.
related codes,
for i=1:6
tt(1)=0;
yol=sqrt((xr(i+1)-xr(i))^2+(yr(i+1)-yr(i))^2);
tt(i+1)=tt(i)+yol/Vr;
end
xrr=horzcat(tt',xr);
yrr=horzcat(tt',yr);
xr - yr values;
3 - 3
2.68060147430381 - 3.13671296448901
4.36591862294010- 6.36978774648130
6.81142757321166- 7.19528445914528
7.75732360564317- 4.90764974391571
8- 5
thanks for helps.
1 Commento
Sriram Tadavarty
il 14 Mag 2020
Hi Sinan,
At the loop 6, the code access xr(6+1) which is not present. Inorder to solve this, you can append zeros at the front of xr and yr. The other one, being looping from 1:5. The actual case depends on what you needed in the output.
Hope this helps.
Regards,
Sriram
Risposte (1)
Ayush Goyal
il 19 Giu 2020
From my understanding of the question you are facing index issue in your code. Since you are iterating your for loop from i=1 to i=6, so when i=6 the code is accessing xr(6+1) and yr(6+1) but the length of both xr and vr vector is 6. You should iterate your for loop for i=1:5 or you can append zeros at the end of xr and yr. You can refer to the following link for how to append to array or vector:
0 Commenti
Vedere anche
Categorie
Scopri di più su Multidimensional Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!