Error: File is too large for MATLAB to run.

Hi all,
After opening a large .m file (140MB), I tried to run it.
I receive the following error:
Error: File is too large for MATLAB to run.
What can I do to resolve this error?

 Accepted Answer

Starting in R2019b, program files larger than approximately 128 MB do not open or run. For files that contain only code (for example, .m and .p files), this limit affects the file size. For files that store more than just code (for example, .mlx files), it affects the size of the code. Running statements larger than 128 MB, either directly in the Command Window or using the eval function, also is not supported. In addition, code with high levels of complexity, such as a large number of deeply nested if statements, is not supported.
Large program file or statement sizes could result in unpredictable behavior and often occurred when using large portions of code (for example, over 500 lines) to define variables with constant values. To decrease the size of program files, consider defining the variables and saving them in a data file (for example, a MAT-file or .csv file). Then you can load the variables instead of executing code to generate them. This adjustment not only decreases the file size of your program but also can increase performance.

5 Comments

Ok, thank you.
It doesn't work at R2019a as you said.
I used Matlab R2016a instead and it worked there.
I encounter a similar issue and would like to ask what would be the appropriate parctice.
Specifically, a symbolic computation -- extranal to maltab -- produces a very large formula (it is 33e6 characters long if I look at it as a string). I want to use maltab to evaluate this formula repeatedly (do parameter sweeps): i.e. assign numerical values to the variables in the formula and retrieve the numerical result. My current, naive, approach is to import the formula as a string and have matlab write a function file with this string forming the function's content. The thus created function file is about 225MB, which can't be loaded/used. Anyone has a suggestion how to do it in another way?
Generally speaking, I suspect that I am doing something quite wrong because I am hitting a limit that should not be one in principle. Maybe people here have advices on how to handle computer-generated function/code.
Thank you in advance.
You are importing the expression as a string and doing text replacement of variable names with constants and fwrite() the result to a file?
Or you import as a string and str2sym() and subs() and matlabFunction() to a file? (if so with 'optimize' true or false)?
Does the overall expression happen to be a sum of terms or product of terms such that no one piece was larger than 100 megabytes or so?
I am curently having similar issue reported by corentin gut. I have a large symbolic expressions that i previously saved to m files (but not using matlabFunction since i run into memory issues), using fopen and fprintf functions. However unfortunately i run into the problem "File is too large for MATLAB to run."
Any way to go around this? I guess that if i use simplify i will have simpler and shorter expressions but it will consume many time.
Regards,
i am using matlab r2022a

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!