Index exceeds - for loop
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, where is the Problem ("index exceeds matrix dimensions")?
With the "for loop" I want to calculate from Line 1 to Line 20
And the Calculation is from value 1 to value 100 each line.
What can I do, to fix the problem?
Many Thanks!!!
2 件のコメント
採用された回答
Turlough Hughes
2019 年 10 月 30 日
The problem is you are specifying indices that dont exist in val. val is a column vector of 10201x1 values, i.e. 10201 rows and 1 column.
When you write val(i,1:100) matlab looks for row i and columns 1 to 100 of val, but there is only one column in your matrix val, hence your index exceeds your matrix dimensions.
3 件のコメント
Turlough Hughes
2019 年 10 月 30 日
I would need to know more about what you are doing. You could convert your 10201 elements to a 101 by 101 array if you wanted...
val_array=reshape(val,[101 101]);
This takes the first 101 elements in column 1, the next 101 in column 2 and so on to column 101, or do you want to populate the new matrix row by row?
val_array=[reshape(val,[101 101])]';
However you will run into the same error as before on line 72 then. I suspect the overall issue lies further up in your code where you generated val.
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!