Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

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

1 view (last 30 days)
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

Answers (0)

This question is closed.

Products

Community Treasure Hunt

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

Start Hunting!