Can someone please help me stop "Index exceeds array bounds." in iteration? Any help is highly appreciated.
4 ビュー (過去 30 日間)
Clayton Gotberg 2021 年 4 月 18 日
編集済み: Clayton Gotberg 2021 年 4 月 18 日
You're asking for elements in x1 that don't exist. If we look only at the last loop n == 8 and you are asking for x1(7), but x1 is defined just before as being a 3x1 matrix of zeros.
I also want to point out that x1 is always zero in the code you posted here, so x will always equal Vj. Additionally, x is being overwritten on every loop instead of the value in each loop being saved.
その他の回答 (1 件)
the cyclist 2021 年 4 月 18 日
In your for loop, when n==5, your code tries to execute
But your vector x1 is length 3, so there is no 4th element to access. That's why you get that error.