Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
Mark Dillon
Mark Dillon am 16 Jul. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Mark Dillon
Mark Dillon am 16 Jul. 2015
Thanks, I guess I didn't realize I posted it in the newsroom and just thought it was lost.

Antworten (0)

Diese Frage ist geschlossen.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by