How can I avoid the fill-in problem?

3 次查看(过去 30 天)
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 个评论
Star Strider
Star Strider 2015-4-26
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.

请先登录,再进行评论。

回答(2 个)

Jan
Jan 2015-4-26
编辑:Jan 2015-4-26
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 个评论
Star Strider
Star Strider 2015-4-26
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.

请先登录,再进行评论。


John D'Errico
John D'Errico 2015-4-26
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.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by