What is the algorithme
?
In order to solve and trace the King's dream fractal, I wrote a short program with MATLAB.
There are 3 parts :
- First,
I initialize all the constants (a, b, c ,d) and the parameters (n, Xo,
Yo).
- Then I make a loop on the time which lasts n times.
- Finally a green graphical ouput is made.
What is the MATLAB
file ?
The MATLAB file is the following one.
clear
close all
% constants
a=-0.966918;
b=2.879879;
c=0.765145;
d=0.744728;
n=3000;
x(1)=1;
y(1)=1;
% compute of x and y
for i=2:n
x(i)=sin(y(i-1)*b)+c*sin(x(i-1)*b);
y(i)=sin(x(i-1)*a)+d*sin(y(i-1)*a);
end
% graphical output
plot(x,y,'g.')