Error using ==> zeros Maximum variable size allowed by the program is exceeded.

5 ビュー (過去 30 日間)
James
James 2011 年 12 月 4 日
I keep getting the error below, the program which creates a (1 x 21) matrix. I have 8 Gb of memory on my pc surely this small matrix doesn't take up this much memory?
??? Error using ==> zeros Maximum variable size allowed by the program is exceeded.
Error in ==> Task1_2_38 at 29 diff = zeros(1:n);
y = -b/2:.1:b/2;
D = .05;
lift_dist = d*v*sqrt(1-((2*y)/b).^2); %lift distribution in this case elliptical
n = length(lift_dist);
for ind = 1:n
circ_dist = lift_dist./(d*v); % circulation distribution
%display(circ_dist)
end
%figure(1)
%plot(y,circ_dist)%plot circulation distribution vs the wing span (y)
%display(y)
%number of sectiond for the airfoill
dy = b/(n-1);
%vector initialization
induced_angle = zeros(1,n);
%Calculate the constants for the induced angle equation:
diff = zeros(1:n);
while (norm(diff) > 1e-5)

採用された回答

Walter Roberson
Walter Roberson 2011 年 12 月 4 日
B = zeros(m,n,p,...) or B = zeros([m n p ...]) returns an m-by-n-by-p-by-... array of zeros.
Now, 1:n is the same as the vector [1 2 3 4 5 6 ... n]
so
zeros(1:n)
is the same as
zeros([1,2,3,4,...n])
which would request factorial(n) array locations. If your n is 21, that would be 51090942171709440000 array locations, which is between 2^65 and 2^66 array locations, and thus would require between 2^68 and 2^69 bytes of storage.
  3 件のコメント
Jan
Jan 2011 年 12 月 4 日
@James: Because "zeros(1, n)" creates a [1 x n] vector.
Did you get the point already? "zeros(1:n)" is very different from "zeros(1, n)".
James
James 2011 年 12 月 4 日
Oh, crap I am an idiot, got it thanks.

サインインしてコメントする。

その他の回答 (1 件)

James
James 2011 年 12 月 4 日
Wow, I feel like an idiot, this is why I should have just went to bed last night.
  1 件のコメント
Walter Roberson
Walter Roberson 2011 年 12 月 4 日
Don't feel too bad. See Matt Fig's answer in
http://www.mathworks.com/matlabcentral/answers/1759-dumb-mistakes-we-make-with-matlab

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by