Why does my for-loop nested in an if-statement not work?
1 view (last 30 days)
Show older comments
Commented: F S on 20 Jul 2016
I have an for-loop inside an if-statement nested again in another for-loop (I know sounds complicated, example below), which seems to run perfeclty, as long as until the loop is called the SECOND time. Then it gives me the error:
Index exceeds matrix dimensions.
Error in code (line 50)
Does anybody have an idea why?
Here the simplified for-if-for-loop:
if sz(2)==512 && sz(3)==512 && vs==2.5
Walter Roberson on 20 Jul 2016
length(proc) is defined as:
length = 0
length = max(size(proc))
You, however, used length(proc) as if it were defined as size(proc,1) . If one of the other dimensions of proc is bigger than the number of rows then that bigger dimension is the length.
More Answers (0)
Find more on Argument Definitions 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!