I have 2 million unknowns with 2 million linear equations. How can I solve them in matlab?
9 ビュー (過去 30 日間)
The problem is that matlab doesn't allow such big matrices. I am only able to solve a system of 45'000 linear equations. The problem is, that when I take like 50'000 equations the error:
Error using rand Requested 60000x60000 (26.8GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.
Do someone have an advice or goaround? Thank you!
PS: I have matlab2015 and 16gb RAM.
回答 (1 件)
Jyotish Robin 2017 年 1 月 17 日
I would suggest you to go to MATLAB > Preferences > Workspace and ensure that the 'Maximum array size limit' is set to 100%. This is to make sure we set the array size limit to the maximum percentage allowed.
After making the above change, type the following in the command window to see the details about memory.
memory displays information showing how much memory is available and how much the MATLAB software is currently using.
The ' maximum possible array' size mentioned in the output indicates the size of largest possible segment of contiguous memory available for the MATLAB to create an array. So we will get an error if we try to allocate an array with a size greater than this maximum size possible.
If that is the case, one possible workaround to work with such large array is to load them in chunks.
Also, If a matrix contains many zeros, converting the matrix to sparse storage saves memory.
>>S = sparse(A)
It converts a full matrix A into sparse form by squeezing out any zero elements. So, depending on your use case, you can make use of this option also.
I hope the above suggestions are helpful in resolving the issue.