For Loop Indexing exceeding array elements

1 回表示 (過去 30 日間)
Liam Gillan
Liam Gillan 2021 年 4 月 4 日
編集済み: Liam Gillan 2021 年 4 月 4 日
Hi I'm trying to make a loop that runs from k=o to k=300 and use the values for some equations from the previous iteration. I can't get it to run without it saying "Index exceeds the number of array elements (1)."

回答 (1 件)

David Fletcher
David Fletcher 2021 年 4 月 4 日
編集済み: David Fletcher 2021 年 4 月 4 日
First run of the loop you are overwriting the z vector with a scaler
if k <= 1
z=5;
mu = 0;
On subsequent runs of the loop you are trying to index the vector that you overwrote with a scaler on the first pass
  1 件のコメント
David Fletcher
David Fletcher 2021 年 4 月 4 日
Without going through the code in microscopic detail, just as a general observation - you've got an awful lot of zeroes kicking around in those arrays set to zero at the start, so any sort of misindexing is likely to result in multiplication by zero - hence getting an awful lot of nothing at the end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Translated by