What to do if my script gives error "The input was too complicated or too big for MATLAB to parse"?

10 Ansichten (letzte 30 Tage)
I have too many loops and I think that is the reason for this error. Is there a work around for such error or would I have to write my entire code again?
Thanks & Regards
  2 Kommentare
aborghes
aborghes am 9 Aug. 2017
Bearbeitet: aborghes am 9 Aug. 2017
The suggested solution to this is to break your code down into multiple functions or files. Another thing you could try would be to use indexing rather than for loops depending on what your use case is. Documentation on indexing can be found here: https://www.mathworks.com/help/matlab/math/matrix-indexing.html
Jan
Jan am 10 Aug. 2017
I've seen codes with 10'000 lines in a single function and 20'000 characters in a line. There were deeply nested loops and a bunch of nested functions. But I've never seen this error message. I do not think that "too many loops" are the reason of the problem.
Could you post a typical part of the code? I'm curious.
I assume you did not write this code for months and run it today the first time. So what has been changed since it ran successfully?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Rik
Rik am 4 Feb. 2024
I know I'm almost 7 years late to the party, but I just ran into this problem and was able to find a source and solution.
For my 12k line file (with almost 1k lines of minified code (which causes several mlint warnings per line)), the cause was an improperly removed conditional block. The code assembling the file was meant to only include the code in the else-block, but it only removed the end statement.
That caused Matlab to think there was deep nesting of functions. Too deep to trigger the warning about end not being alligned with the matching for/if. Removing blocks of code eventually reduced the number of mlint warnings (and/or the nesting) sufficiently to let this error through.

Kategorien

Mehr zu Loops and Conditional Statements 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!

Translated by