Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

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

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Mark Dillon
Mark Dillon il 16 Lug 2015
Thanks, I guess I didn't realize I posted it in the newsroom and just thought it was lost.

Risposte (0)

Questa domanda è chiusa.

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by