How can I avoid the fill-in problem?

3 views (last 30 days)
I would like to know if there is a way to avoid the fill-in problem adding some code lines to the script. The thing is that when that happens to me the computer doesn't respond at all. I can't even open msconfig to stop the program from there, so I just end up turning off the computer. If this happened to me in the middle of an exam, I don't think it would be very pleasant.
  6 Comments
Star Strider
Star Strider on 26 Apr 2015
The only solution I’ve found is going to the Task Manager (Windows) and closing MATLAB from there, since it also won’t respond to clicking the red x at the top right of the MATLAB window.
I agree, it would be nice if there was some sort of warning. Put in an enhancement request for something that monitored memory usage, and could have the user set a threshold for matrix size.
The time I most recently encountered it was when I was doing a simple linear regression with long vectors. As the first column (a column vector of ones used to calculate the intercept), I mistakenly typed ‘ones(length(x))’ instead of ‘ones(length(x),1)’. That essentially crashed MATLAB, at least by my definition.
Ricardo Boza Villar
Ricardo Boza Villar on 26 Apr 2015
Many thanks to the three of you.

Sign in to comment.

Answers (2)

Jan
Jan on 26 Apr 2015
Edited: Jan on 26 Apr 2015
You can limit the size of created arrays in Matlab 2015a. See http://www.mathworks.com/help/matlab/release-notes.html "Array Size Limit" (Sorry, this link will not work anymore when R2015b is released)
With older Matlab versions you cannot prevent that the user provides insane commands. And even with the newest version a stubborn or careless user can kill the machine.
  1 Comment
Star Strider
Star Strider on 26 Apr 2015
I missed that when I read the Release Notes. Thanks.
I hope the functionality still exists in R2015b.
The link may work if the documentation for previous versions remains. It just won’t redirect to the R2015b documentation.

Sign in to comment.


John D'Errico
John D'Errico on 26 Apr 2015
I'm sorry, but there is simply no substitute for thinking about what you are doing. Look at what you have written before you hit enter, before you cause the code to execute. If you are unsure about it, test out a code fragment on a small problem.
Write modular code. Test each module separately. Then when you put it all together, you can be confident it will run smoothly.
The fact is, once you get used to being careful in your coding, code gets easy to write, because you KNOW that it will work as you have written it.

Categories

Find more on Loops and Conditional Statements 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!