Index out of bounds error but cannot see why variable isn't generating properly.
1 view (last 30 days)
Show older comments
Hi,
I'm running some code that isn't mine (the original author is unable to respond currently) and I'd like to see if I can resolve it fairly quick. I get the below error and I know its because the bounds_stress_ratio variable only has one field and the codes trying to look for a second value (bug is occuring on line 136). However, I can't see why theres only one value in the bounds_stress_ratio variable and how to correct it.

The code was written in a more up to date version of Matlab than I run (2013a student addition) and i've change it earlier to make it more compatable. I am wondering if some of these changes have caused this error. If so, can anyone please let me know when I went wrong and what alternative I should use to fix it.
The changes made earlier in the code are below, on line 48 it used categorical and I changed it to nominal and on line 52 i changed it to char (was character). Categorical and character don't work in my version of Matlab.

I also removed the {f } brackets and change it to (f) on lines 90,91 and 92 due to a different error.

All variables created earlier in the code seem to be fine so i've been unable to track where the error starts
Thanks heaps.
0 Comments
Answers (1)
Neuropragmatist
on 9 Aug 2019
This is really hard to debug without the actual code (generally posting the actual code is far more helpful than posting images of the code).
I would suggest typing 'keyboard' just before line 135. Run the code and Matlab should pause where you typed 'keyboard'.
Then you can tell us the size of the different variables. Because bounds_sig_p_m and pa must both be integers for bounds_stress_ratio to only have one element. So you will need to trace the error back up through the code and see why/where your variables are becoming single value integers.
At a glance it looks like all of the variables in your first screenshot must be single element vectors, so the problem seems to occur outside the scope of your screenshots.
Possibly something is up with your loop and col_vs{f} etc are all empty for some reason?
M.
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!