%HENON is a script file to illustrate the Chaotic Control Algorithm on the Henon map

% Last modified on October 12, 1998 by S. H. Zak

clear
U_max=0.3;
V_max=0.0109;
x_e=[0.6314 0.1894]';
x_0=-0.5;
y_0=0;
x=x_0;
y=y_0;
axis([-1.5 1.5 -.4 .4]);
hold on
plot(x,y,'linestyle','O','markersize',6,'erasemode','none');
text(x+.04,y,'IC','Fontsize',12)
drawnow
P=[1.1902 -0.0686;-0.0686 1.0489];
K=[-1.5008 0.7974];
xx=linspace(-1.5,1.5,150);
yy=linspace(-0.4,0.4,100);
[XX,YY]=meshgrid(xx,yy);
Z=1.1902.*(XX-x_e(1)).^2-2*0.0686.*(XX-x_e(1)).*(YY-x_e(2))+1.0489*(YY-x_e(2)).^2;
contour(xx,yy,Z,[0.0109 0.0109])
for i=1:25
V=[(x-x_e(1)) (y-x_e(2))]*P*[(x-x_e(1));(y-x_e(2))];
if V<V_max
u_arg=-K*[(x-x_e(1));(y-x_e(2))];
fx='-1.4*x^2+y+1+U_max*l_sat(u_arg/U_max)';
fy='0.3*x';
else
fx='-1.4*x^2+y+1';
fy='0.3*x';
end
f1(i)=eval(fx);
f2(i)=eval(fy);
x=f1(i);
y=f2(i);
if V>=V_max
plot(x,y,'linestyle','*','markersize',6)
text(x+.04,y,int2str(i),'Fontsize',12)
else
plot(x,y,'linestyle','.')
end
drawnow
end
xlabel('{\it x}_1','Fontsize',12)
ylabel('{\it x}_2','Fontsize',12)
title('An orbit of the controlled Henon map','Fontsize',12)
set(gca,'Fontsize',12)
figure;
plot([0:1:25],[x_0 f1],'*');xlabel('Iteration','Fontsize',12);ylabel('{\it x}_1','Fontsize',12)
title('A plot of {\it x}_1 versus time for the controlled Henon map','Fontsize',12)
set(gca,'Fontsize',12),grid
figure;
plot([0:1:25],[y_0 f2],'*');xlabel('Iteration','Fontsize',12);ylabel('{\it x}_2','Fontsize',12)
title('A plot of {\it x}_2 versus time for the controlled Henon map','Fontsize',12)
set(gca,'Fontsize',12),grid
