- 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 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Stephen23
am 19 Jan. 2016
Bearbeitet: Stephen23
am 19 Jan. 2016
@t v: please edit your question, and do all of the following:
Antworten (1)
jgg
am 19 Jan. 2016
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 Kommentare
jgg
am 20 Jan. 2016
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.
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!