Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Why do I keep getting back 'Error using zeros' when I run my script?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
Respuestas (0)
La pregunta está cerrada.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!