- delete the code from your question. So much code is difficult to read.
- upload the code by clicking the paperclip button, then both the Choose file and Attach file buttons.
- Show us all of the error message. This means all of the red text. We need the complete error message because it gives us useful information.
Index exceeds matrix dimensions
3 ビュー (過去 30 日間)
古いコメントを表示
Hello, I am receiving an error at line 74 and was curious why this error is occurring and what I should do to resolve the issue.
Index exceeds matrix dimensions.
Error in NonConvective (line 74)
bigDATA(ii, bigDATAstart:(bigDATAstart - 1 +length(goodPoints))) = a(goodPoints);
2 件のコメント
Stephen23
2016 年 1 月 19 日
編集済み: Stephen23
2016 年 1 月 19 日
@t v: please edit your question, and do all of the following:
回答 (1 件)
jgg
2016 年 1 月 19 日
Your problem is this:
bigDATA = nan(16, 100000);
This is a 16x100,000 matrix of NaNs.
ii_array = [198 139 81 80 84 238 63 353 43 159 92 62 66 73 6 7 238 239 246 156 140 141 361 362 366];
This is a 1x25 vector, so this length(ii_array) is 25. Therefore:
for ii = 1:length(ii_array)
bigDATA(ii, bigDATAstart:(bigDATAstart - 1 +length(goodPoints))) = a(goodPoints);
%%snip
end
This loop, where you get your error, is looking to store a(goodPoints) into element 17 of a 16x100,000 matrix, which throws the error. You need to either fix your indexing or make your bigData matrix correct. I don't understand your code well enough to tell you which one, but I suggest you need to carefully walk through it to make sure it's working as intended. Try using the keyboard command and walking through your loops.
2 件のコメント
jgg
2016 年 1 月 20 日
You need to post all your code; I can't see what you are doing. I'd suggest trying to debug this by in the editor under breakpoints, click dbstop if error. Then, when your program errors you can check to see what is going on.
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!