PROGRAMS


 
 

For this project I wrote three programs in matlab:
  - attractor's program
  - bifurcation diagram program
  - deformation of a square
 

Attractor's program:

n=input('n= ');
c2=input('c2= ');
x0=input('x(1)= ');
y0=input('y(1)= ');
c1=0.4;
c3=6.0;
rho=1;

x=zeros(1,n+1);
y=zeros(1,n+1);
x(1)=x0; y(1)=y0;

for i =1:n
  temp(i)=c1-c3/(1+x(i)*x(i)+y(i)*y(i));
  sintemp(i)=sin(temp(i));
  costemp(i)=cos(temp(i));
  x(i+1)= rho+c2*(x(i)*costemp(i)-y(i)*sintemp(i));
  y(i+1)=c2*(x(i)*sintemp(i)+y(i)*costemp(i));
  end

figure1=plot(x, y, '.');
grid;
 
 

Bifurcation diagram program:

clear;
n=input('n= ');
c2=0:0.001:1;
c1=0.4;
c3=6.0;
rho=1;
x(:,1)=zeros(size(c2,2),1);
y(:,1)=zeros(size(c2,2),1);

for k=1 : size(c2,2)
   for i=1:130
  temp(k,i)=c1-c3/(1+x(k,i)*x(k,i)+y(k,i)*y(k,i));
  sintemp(k,i)=sin(temp(k,i));
  costemp(k,i)=cos(temp(k,i));
  x(k,i+1)= rho+c2(k)*(x(k,i)*costemp(k,i)-y(k,i)*sintemp(k,i));
  y(k,i+1)=c2(k)*(x(k,i)*sintemp(k,i)+y(k,i)*costemp(k,i));
   end
end

a=c2(1,1)*ones(1,51);
b=x(1,80:130);
for j=2 : size(c2,2)
 a=[a,c2(1,j)*ones(1,51)];
 b=[b,x(j,80:130)];
end

plot(a,b,'m.');
xlabel('lambda');
ylabel('x');
axis([0. 1. -8. 8.]);
grid;
 

Deformation of a square:

n = input('n = ');
c1=0.4;
c2=0.9;
c3=6.0;
rho=1;

x=zeros(1,n+1);
y=zeros(1,n+1);
 
for x0= 0 : 0.05 : 1
    x(1)=x0;
   for y0= 0 : 0.05 : 1
     y(1)=y0;
      for i=1: n
        temp(i)=c1-c3/(1+x(i)*x(i)+y(i)*y(i));
        sintemp(i)=sin(temp(i));
        costemp(i)=cos(temp(i));
        x(i+1)= rho+c2*(x(i)*costemp(i)-y(i)*sintemp(i));
        y(i+1)=c2*(x(i)*sintemp(i)+y(i)*costemp(i));
      end
     hold on;
     plot(x(n), y(n), 'm.');
   end
end
grid;