フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Why do I keep getting back 'Error using zeros' when I run my script?

1 回表示 (過去 30 日間)
Mark Dillon
Mark Dillon 2015 年 7 月 16 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Each time I run my script I get this:
Error using zeros
Maximum variable size allowed by the program is exceeded.
Error in HW3_2 (line 9)
x = zeros(1:50001);
Here is the script I am running:
%%Fractal Curves / Chaos Game / Dragon Curve
% Initially x=0 and y=1, then goes through 50k iterations
x = zeros(1:50001);
y = ones(1:50001);
% Randi - Uniformly distributed pseudorandom integers
% For example:
% X=randi(max) returns a pseudorandom scalar integer between 1 and max.
% Rules
% 1: x(n+1)=(x(n)-y(n))/4 - (1/2) and y(n+1)=(x(n)+y(n))/4 + 1
% 2: x(n+1)=(y(n)-x(n))/4 + (1/2) and y(n+1)=-(y(n)+x(n))/4 + 1
% 3: x(n+1)=(x(n)+y(n))/2 + 1 and y(n+1)=(y(n)-x(n))/2
%%Finding values for x and y
for k = 1:length(x)-1
rule = randi(3); % See definition above in line 12-14
if rule == 1
x(k+1)=(x(k)-y(k))/4 - (1/2);
y(k+1)=(x(k)+y(k))/4 + 1;
elseif rule == 2
x(k+1)=(y(k)-x(k))/4 + (1/2);
y(k+1)=-(y(k)+x(k))/4 + 1;
elseif rule == 3
x(k+1)=(x(k)+y(k))/2;
y(k+1)=(y(k)-x(k))/2;
end
end
plot(x,y,'.r');
title('Partial Boundary of Dragon Curve');
I have been troubleshooting this for a day, and cannot figure out why. Please help.
Thanks
  2 件のコメント
Steven Lord
Steven Lord 2015 年 7 月 16 日
Did you read the responses to your question on the newsgroup?
Mark Dillon
Mark Dillon 2015 年 7 月 16 日
Thanks, I guess I didn't realize I posted it in the newsroom and just thought it was lost.

回答 (0 件)

この質問は閉じられています。

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by