不知道这个有没有用?http://www.mathworks.com/support/solutions/data/26623.html Problem Description How do I pre-allocate memory when using MATLAB? I have several FOR loops in my M-file. I have tried using the PACK function, but I continue to get "out of memory" errors. Solution: FOR loops can cause memory fragmentation problems because MATLAB does not know how big the final matrix array will be upon the conclusion of the FOR loop. For example, look at the following FOR loop: for i=1:10 x(i)=i; end When th
【在 x*****u 的大作中提到】 : 不知道这个有没有用?http://www.mathworks.com/support/solutions/data/26623.html : Problem Description : How do I pre-allocate memory when using MATLAB? I have several FOR loops in my : M-file. I have tried using the PACK function, but I continue to get "out of : memory" errors. : Solution: : FOR loops can cause memory fragmentation problems because MATLAB does not know : how big the final matrix array will be upon the conclusion of the FOR loop. : For example, look at the following FOR loop: : for i=1:10