0% found this document useful (0 votes)
48 views32 pages

Fpic Tdas

This document contains MATLAB code that analyzes the stability of a system using different control strategies. It defines system parameters and matrices, calculates the steady state operating point, and uses the eigenvalues of derived matrices to determine stability based on control gains. Functions are defined to calculate the steady state, exponential matrices, and Jacobian matrices needed for stability analysis under proportional-integral (FPIC), two-degree of freedom (TDAS) and feedback linearization (Fpic) control. Plots of stable and unstable regions are generated based on iterating control gains.

Uploaded by

Dario Vergara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views32 pages

Fpic Tdas

This document contains MATLAB code that analyzes the stability of a system using different control strategies. It defines system parameters and matrices, calculates the steady state operating point, and uses the eigenvalues of derived matrices to determine stability based on control gains. Functions are defined to calculate the steady state, exponential matrices, and Jacobian matrices needed for stability analysis under proportional-integral (FPIC), two-degree of freedom (TDAS) and feedback linearization (Fpic) control. Plots of stable and unstable regions are generated based on iterating control gains.

Uploaded by

Dario Vergara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 32

function CotaFPICKk1Daro

%%% veamos
T=.18;
gamma=.35;
x1ref=2.5;
k1=linspace(-0.5,0.5,50);
k2=0.5;
k3=0;
k4=linspace(0,1,50);%constante de control
establek1=[];
inestablek1=[];
establek4=[];
inestablek4=[];
for i=1:length(k1)
for j=1:length(k4)
rho=regulacionauxFPIC(k1(i),k2,k3,k4(j),T,gamma,x1ref);
clc
if rho<1
establek1=[establek1,k1(i)];
establek4=[establek4,k4(j)];
else
inestablek1=[inestablek1,k1(i)];
inestablek4=[inestablek4,k4(j)];
end
end
end
plot(establek1,establek4,'s','markerface','b','markersize',2)
hold on
plot(inestablek1,inestablek4,'sr','markerface','r','markersize',2)
i1=num2str(k1);
i2=num2str(k2);
i3=num2str(k3);
i4=num2str(x1ref);
i5=num2str(gamma);

xlabel({'k_1';'';['k_2=',i2,' , ','k_3=',i3,' , ','Referencia=',i4,' ,


','\gamma=',i5]}),ylabel('Constante de control FPIC')
end
function rho=regulacionauxFPIC(k1,k2,k3,k4,T,gamma,x1ref)
x2ref=(x1ref)^(2)*gamma;
dss=(1-(1/x1ref))*T;
X0=Estabilidad1P(k1,k2,k3,T,gamma,x1ref);%%%%%%%%%%%%
%%%%%%%%%%%%%%%
x10=X0(1);
x20=X0(2);
A1=[-gamma 0 ; 0 0];
A2=[-gamma 1 ; -1 0];
B=[0;1];
K=[k1 k2 k3];
A1aux=[-gamma 0 0; 0 0 0; 1 0 0];
Baux=[0;1;-x1ref];
A2aux=[-gamma 1 0; -1 0 0; 1 0 0];
Xref=[x1ref;x2ref;0];
%%%%%%%%%%%%%%%%%%%
X0=[x10;x20;0];%%condicion inicial sistema
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%
s=K*(X0-Xref);
s1=K*(A1aux*X0+Baux);
s2=K*(A2aux*X0+Baux);
d1=((2*s+T*s2)/(s2-s1));
d=((d1+k4*dss)/(k4+1));
X0(3)=[];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%
phi1=expm(A1*(d/2));
phi2=expm(A2*(T-d));
psi1=B*(d/2);
psi2=A2\(expm(A2*(T-d))-eye(2))*B;
dP1=phi1*phi2*phi1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%
dT=((1/2)*A1*phi1*phi2*phi1+phi1*((1/2)*phi2*A1*phi1A2*phi2*phi1))*X0;
dQ=(1/2)*(A1*phi1*phi2*psi1+phi1*phi2*B)-phi1*A2*phi2*psi1;
dR=(1/2)*A1*phi1*psi2-phi1*phi2*B;
dS=(1/2)*B;
dP2=dT+dQ+dR+dS;%%%%%%%%%%%
%%DERIVADA DEL CICLO DE TRABAJO RESPECTO A X
M=2*(k1)^2+2*(k2)^2+T*k1*k3-T*gamma*(k1)^2;
N=T-2*x2ref;
F=(1/(k1*x20-k2*x10)^2);
dP3=(1/(k4+1))*F*[M*x20+N*(k2)^2-x1ref*(2*k1*k2+T*k2*k3),(M*x10+N*k1*k2-x1ref*(2*(k1)^2+T*k1*k3))];
dP=dP1+(dP2*dP3);
eigenvalores=eig(dP)';
rho=max([abs(eigenvalores(1)),abs([eigenvalores(2)])]);
end
%%%%funcion Estabilidad
function X0=Estabilidad1P(k1,k2,k3,T,gamma,x1ref);
x2ref=(x1ref)^(2)*gamma;

x10=x1ref;
x20=x2ref;
x30=0;
A1=[-gamma 0 ; 0 0];
A2=[-gamma 1 ; -1 0];
B=[0;1];
A1aux=[-gamma 0 0; 0 0 0; 1 0 0];
A2aux=[-gamma 1 0; -1 0 0; 1 0 0];
Baux=[0;1;-x1ref];
K=[k1 k2 k3];
X0=[x10;x20;0];
Xref=[x1ref;x2ref;0];
options=optimset('Display','iter');
X0=fsolve(@boostZAD,X0,
[],A1aux,A2aux,Baux,A1,A2,B,K,T,gamma,x1ref,x2ref);%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s=K*(X0-Xref);
s1=K*(A1aux*X0+Baux);
s2=K*(A2aux*X0+Baux);
d=((2*s+T*s2)/(s2-s1));%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%Normalizando
%%%%%Estraegia zad%%%%%%%
function
F=boostZAD(X0,A1aux,A2aux,Baux,A1,A2,B,K,T,gamma,x1ref,x2ref)
;
Xref=[x1ref;x2ref;0];
s=K*(X0-Xref);
s1=K*(A1aux*X0+Baux);
s2=K*(A2aux*X0+Baux);
d=((2*s+T*s2)/(s2-s1));

X0aux=X0(3);
X0(3)=[];
phi1=expm(A1*d/2);
psi1=B*d/2;
phi2=expm(A2*(T-d));
psi2=A2\(expm(A2*(T-d))-eye(2))*B;%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%
X=phi1*phi2*phi1*X0+phi1*phi2*psi1+phi1*psi2+psi1;
X0(3)=X0aux;
X=[X;0];
F=[X0-X];
end
end
function CotasTdasDaro
T=.18;
gamma=.35;
x1ref=2.5;
k1=linspace(-0.5,0.5,50);
k2=0.5;
k3=0;
eta=linspace(-0.7,0,50);
establek1=[];
inestablek1=[];
estableeta=[];
inestableeta=[];
clc
for i=1:length(k1)
for j=1:length(eta)

rho=regulacionauxTDAS(k1(i),k2,k3,eta(j),T,gamma,x1ref);
clc
if rho<1
establek1=[establek1,k1(i)];
estableeta=[estableeta,eta(j)];
else
inestablek1=[inestablek1,k1(i)];
inestableeta=[inestableeta,eta(j)];
end
end
end
plot(establek1,estableeta,'s','markerface','b','markersize',2)%
hold on
plot(inestablek1,inestableeta,'sr','markerface','r','markersize',2)
i1=num2str(k1);
i2=num2str(k2);
i3=num2str(k3);
i4=num2str(x1ref);
i5=num2str(gamma);
xlabel({'k_1';'';['k_2=',i2,' , ','k_3=',i3,' , ','Referencia=',i4,' ,
','\gamma=',i5]}),ylabel('Constante de control TDAS')
end
function rho=regulacionauxTDAS(k1,k2,k3,eta,T,gamma,x1ref)

x2ref=(x1ref)^(2)*gamma;

X0=Estabilidad1P(k1,k2,k3,T,gamma,x1ref);%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%5

x10=X0(1);
x20=X0(2);

A1=[-gamma 0 ; 0 0];
A2=[-gamma 1 ; -1 0];
B=[0;1];
K=[k1 k2 k3];
A1aux=[-gamma 0 0; 0 0 0; 1 0 0];
Baux=[0;1;-x1ref];
A2aux=[-gamma 1 0; -1 0 0; 1 0 0];
Xref=[x1ref;x2ref;0];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%
X0=[x10;x20;0];%%condicion inicial sistema
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s=K*(X0-Xref);
s1=K*(A1aux*X0+Baux);
s2=K*(A2aux*X0+Baux);
d=((2*s+T*s2)/(s2-s1));
if d==0
phi2=expm(A2*T);
dP=phi2;
eigenvalores=eig(dP)';
rho=max([abs(eigenvalores(1)),abs([eigenvalores(2)])]);
else
X0(3)=[];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
phi1=expm(A1*(d/2));
phi2=expm(A2*(T-d));
psi1=B*(d/2);
psi2=A2\(expm(A2*(T-d))-eye(2))*B;
dP1=phi1*phi2*phi1;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
dT=((1/2)*A1*phi1*phi2*phi1+phi1*((1/2)*phi2*A1*phi1A2*phi2*phi1))*X0;
dQ=(1/2)*(A1*phi1*phi2*psi1+phi1*phi2*B)-phi1*A2*phi2*psi1;
dR=(1/2)*A1*phi1*psi2-phi1*phi2*B;
dS=(1/2)*B;
dP2=dT+dQ+dR+dS;%%%%%%%%%%%
%%DERIVADA DEL CICLO DE TRABAJO RESPECTO A X
M=2*(k1)^2+2*(k2)^2+T*k1*k3-T*gamma*(k1)^2;
N=T-2*x2ref;
F=(1/(k1*x20-k2*x10)^2);
dP3=F*[M*x20+N*(k2)^2-x1ref*(2*k1*k2+T*k2*k3),(M*x10+N*k1*k2-x1ref*(2*(k1)^2+T*k1*k3))];

J1=[dP1,zeros(2,2);eye(2,2),zeros(2,2)];
J2=[(1/(1-eta))*(dP2*dP3),(eta/(eta1))*(dP2*dP3);zeros(2,2),zeros(2,2)];
dP=J1+J2;

eigenvalores=eig(dP)';
rho=max([abs(eigenvalores(1)),abs([eigenvalores(2)]),abs([eigenval
ores(3)]),abs([eigenvalores(4)])]);
end
end
function X0=Estabilidad1P(k1,k2,k3,T,gamma,x1ref);
x2ref=(x1ref)^(2)*gamma;
x10=x1ref;
x20=x2ref;
x30=0;
A1=[-gamma 0 ; 0 0];
A2=[-gamma 1 ; -1 0];
B=[0;1];
A1aux=[-gamma 0 0; 0 0 0; 1 0 0];
A2aux=[-gamma 1 0; -1 0 0; 1 0 0];
Baux=[0;1;-x1ref];
K=[k1 k2 k3];
X0=[x10;x20;0];
Xref=[x1ref;x2ref;0];
options=optimset('Display','iter');
X0=fsolve(@boostZAD,X0,
[],A1aux,A2aux,Baux,A1,A2,B,K,T,gamma,x1ref,x2ref);%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s=K*(X0-Xref);
s1=K*(A1aux*X0+Baux);
s2=K*(A2aux*X0+Baux);
d=((2*s+T*s2)/(s2-s1));%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%Normalizando
end

%%%%%Estraegia zad%%%%%%%
function
F=boostZAD(X0,A1aux,A2aux,Baux,A1,A2,B,K,T,gamma,x1ref,x2ref)
Xref=[x1ref;x2ref;0];
s=K*(X0-Xref);
s1=K*(A1aux*X0+Baux);
s2=K*(A2aux*X0+Baux);
d=((2*s+T*s2)/(s2-s1));
X0aux=X0(3);
X0(3)=[];
phi1=expm(A1*d/2);
psi1=B*d/2;
phi2=expm(A2*(T-d));
psi2=A2\(expm(A2*(T-d))-eye(2))*B;%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%
X=phi1*phi2*phi1*X0+phi1*phi2*psi1+phi1*psi2+psi1;
X0(3)=X0aux;
X=[X;0];
F=[X0-X];
end

Fpic
close all
clear all
clc
N=2500;
rho1 =0.2782;rho2 = 0.2371;k2=0.5;T=0.18; gamma = 0.1860; Vt
=0.0274; %E=40.086 fuente conmutada
x1ref= 2.1;
x2ref=(gamma*x1ref)/2 + ((2*gamma*rho1*x1ref 4*gamma*rho1*x1ref^2 - 2*gamma*rho2*x1ref +
gamma^2*rho1^2*x1ref^2 + gamma^2*rho2^2*x1ref^2 4*Vt*gamma*rho1*x1ref - 2*gamma^2*rho1*rho2*x1ref^2 +
1)^(1/2) - gamma*rho2*x1ref + 1)/(2*rho1);
%
k1=2.14;
k2=0.5;
n=0.2;
A1=[-gamma 0 ; 0 -rho1];
A2=[-gamma 1 ; -1 -rho2];
B1=[0;1];
B2=[0;1-Vt];
K=[k1 k2];

Xref=[x1ref;x2ref];
X0=Xref;
aux1=[X0(1)];
aux2=[X0(2)];
dss=-(T*k2*rho2 - 2*T*k2*rho1 - T*k1 - T*k1*(2*gamma*rho1*x1ref
- 4*gamma*rho1*x1ref^2 - 2*gamma*rho2*x1ref +
gamma^2*rho1^2*x1ref^2 + gamma^2*rho2^2*x1ref^2 4*Vt*gamma*rho1*x1ref - 2*gamma^2*rho1*rho2*x1ref^2 +
1)^(1/2) + 2*T*k2*rho1*x1ref + T*k2*rho2*(2*gamma*rho1*x1ref 4*gamma*rho1*x1ref^2 - 2*gamma*rho2*x1ref +
gamma^2*rho1^2*x1ref^2 + gamma^2*rho2^2*x1ref^2 4*Vt*gamma*rho1*x1ref - 2*gamma^2*rho1*rho2*x1ref^2 +
1)^(1/2) + 2*T*Vt*k2*rho1 + T*gamma*k1*rho1*x1ref +
T*gamma*k1*rho2*x1ref - T*gamma*k2*rho2^2*x1ref +
T*gamma*k2*rho1*rho2*x1ref)/(k1 + k2*rho1 - k2*rho2 +
k1*(2*gamma*rho1*x1ref - 4*gamma*rho1*x1ref^2 2*gamma*rho2*x1ref + gamma^2*rho1^2*x1ref^2 +
gamma^2*rho2^2*x1ref^2 - 4*Vt*gamma*rho1*x1ref 2*gamma^2*rho1*rho2*x1ref^2 + 1)^(1/2) - 2*Vt*k2*rho1 2*k2*rho1*x1ref + k2*rho1*(2*gamma*rho1*x1ref 4*gamma*rho1*x1ref^2 - 2*gamma*rho2*x1ref +
gamma^2*rho1^2*x1ref^2 + gamma^2*rho2^2*x1ref^2 4*Vt*gamma*rho1*x1ref - 2*gamma^2*rho1*rho2*x1ref^2 +
1)^(1/2) - k2*rho2*(2*gamma*rho1*x1ref - 4*gamma*rho1*x1ref^2
- 2*gamma*rho2*x1ref + gamma^2*rho1^2*x1ref^2 +
gamma^2*rho2^2*x1ref^2 - 4*Vt*gamma*rho1*x1ref 2*gamma^2*rho1*rho2*x1ref^2 + 1)^(1/2) +
gamma*k1*rho1*x1ref - gamma*k1*rho2*x1ref +
gamma*k2*rho1^2*x1ref + gamma*k2*rho2^2*x1ref 2*gamma*k2*rho1*rho2*x1ref)
s=K*(X0-Xref);
s1=K*(A1*X0+B1);
s2=K*(A2*X0+B2);
d(1)=((2*s+T*s2)/(s2-s1))/T;
for i=2:N

s=K*(X0-Xref);
s1=K*(A1*X0+B1);
s2=K*(A2*X0+B2);
d(i)=((2*s+T*s2)/(s2-s1))/T;
d(i)=(d(i)+n*dss)/(n+1);
%
%
%
if 0<d(i) & d(i)<1
phi1=expm(A1*d(i)/2*T);
psi1=A1\(expm(A1*d(i)/2*T)-eye(2))*B1;
Y0=phi1*X0+psi1;
phi2=expm(A2*(T-d(i)*T));
psi2=A2\(expm(A2*(T-d(i)*T))-eye(2))*B2;%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%
Z0=phi2*Y0+psi2;
X=phi1*Z0+psi1;
X0=X;
elseif d(i)<=0
%
d(i)=0;
phi2=expm(A2*T);
psi2=A2\(expm(A2*T)-eye(2))*B2;%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
X=phi2*X0+psi2;

X0=X;
elseif d(i)>=1
d(i)=1;
phi1=expm(A1*T);
psi1==A1\(expm(A1*T)-eye(2))*B1;
X=phi1*X0+psi1;
X0=X;
end

aux1=[aux1,X(1)];
aux2=[aux2,X(2)];
%X0=X ;
end
figure(1)
plot(aux1,aux2,'.b','markersize',2),xlabel('x_1'),ylabel('x_2')
title('Mapa de Poincare \{1,0,1\}')
i2=num2str(k1);
i3=num2str(k2);
i4=num2str(T);
i5=num2str(n);
xlabel(['k1= ',i2,',k2= ',i3,',T= ',i4, ',constante fpic= ',i5])
hold on
figure(2)
subplot(211)
plot(x1ref*ones(1,N),'r')
hold on
plot(aux1,'.b','markersize',2),ylabel(' x_1')
title('Comportamiento de la Regulacin')

hold on
subplot(212)
plot(x2ref*ones(1,N),'r')
hold on
plot(aux2,'.b','markersize',2),ylabel(' x_2')
hold on
i2=num2str(k1);
i3=num2str(k2);
i4=num2str(T);
i5=num2str(n);
xlabel(['k1= ',i2,',k2= ',i3,',T= ',i4, ',constante fpic= ',i5])
hold on
figure(3)
plot(d,'.b','markersize',2)
title('Evolucion del ciclo de Trabajo vs. Nmero de periodos')
i2=num2str(k1);
i3=num2str(k2);
i4=num2str(T);
i5=num2str(n);
xlabel(['k1= ',i2,',k2= ',i3,',T= ',i4, ',constante fpic= ',i5])
hold on
hold of

Poincare
close all
clear all
clc
N=1500;

gamma=.35;

x10=1.93376458096729;
x20=1.48670563176528;
x30=0;
x10=2.05951117948505;
x20=1.30670563176528;
x30=0;
x1ref=2.5;
x2ref=(x1ref)^(2)*gamma; %%2.18750000000000

k1=-.25;
k2=.4;
k3=-4.7;

T=0.18;

A1=[-gamma 0 ; 0 0];
A2=[-gamma 1 ; -1 0];
B=[0;1];
K=[k1 k2 k3];
A1aux=[-gamma 0 0; 0 0 0; 1 0 0];
Baux=[0;1;-x1ref];
A2aux=[-gamma 1 0; -1 0 0; 1 0 0];
Xref=[x1ref;x2ref;0];
X0=[x10;x20;x30];

%X0=Xref;
aux1=[X0(1)];
aux2=[X0(2)];
for i=1:N
s=K*(X0-Xref);
s1=K*(A1aux*X0+Baux);
s2=K*(A2aux*X0+Baux);
d(i)=((2*s+T*s2)/(s2-s1))/T;
X0(3)=[];
if 0<d(i) & d(i)<1
phi1=expm(A1*d(i)/2*T);
psi1=B*d(i)/2*T;
phi2=expm(A2*(T-d(i)*T));
psi2=A2\(expm(A2*(T-d(i)*T))-eye(2))*B;%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
X=phi1*phi2*phi1*X0+phi1*phi2*psi1+phi1*psi2+psi1;
X=[X;0];
elseif d(i)<=0
d(i)=0;
phi2=expm(A2*T);
psi2=A2\(expm(A2*T)-eye(2))*B;%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%

X=phi2*X0+psi2;
X=[X;0];
elseif d(i)>=1
d(i)=1;
phi1=expm(A1*T);
psi1=B*T;
X=phi1*X0+psi1;
X=[X;0];
end
aux1=[aux1,X(1)];
aux2=[aux2,X(2)];
X0=X;
end
plot(aux1,aux2,'+r','markersize',2),ylabel('x_2')
hold on
i1=num2str(k1);
i2=num2str(k2);
i3=num2str(k3);
i4=num2str(gamma);
xlabel({'x_1';'';['k_1=',i1,' , ','k_2=',i2,' , ','k_3=',i3]})
%%%%ploteo de cuadro de referencia
hold on
plot(x1ref*ones(1,100),linspace(0,x2ref),':k','markersize',2)
hold on
plot(linspace(0,x1ref),x2ref*ones(1,100),':k','markersize',2)

hold on
plot(linspace(0,x1ref),zeros(1,100),':k','markersize',2)
hold on
%X=Estabilidad1Paux(k1,k2,k3,T,gamma)
F=[aux1(:,end);aux2(:,end)]
G=[aux1(:,end-1);aux2(:,end-1)]
figure(2)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%5
subplot(211)
plot(x1ref*ones(1,N),'r')
hold on
plot(aux1,'+','markersize',2),ylabel('x_1'),xlabel('Periodos')
hold on
i1=num2str(k1);
i2=num2str(k2);
i3=num2str(k3);
i4=num2str(gamma);
subplot(212)
plot(x2ref*ones(1,N),'r')
hold on
plot(aux2,'+','markersize',2),ylabel(' x_2'),xlabel('Periodos')
xlabel({'Periodos';'';['k_1=',i1,' , ','k_2=',i2,' , ','k_3=',i3]})
figure(3)
plot(d,'+','markersize',2), ylabel('Ciclo de trabajo normalizado')
hold on
i1=num2str(k1);
i2=num2str(k2);
i3=num2str(k3);
i4=num2str(gamma);
xlabel({'Periodos';'';['k_1=',i1,' , ','k_2=',i2,' , ','k_3=',i3]})

f=1-(1/(x1ref));
plot(f*ones(1,N),'g')
hold of

Regulacion TDAS
clc
close all
clear all

N=50;
gamma=.35;

x1ref=2.5;
x2ref=(x1ref)^(2)*gamma;
k1=-.25;
k2=.4;
k3=-4.5;
eta=-.25;%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%constante de retroalimentacion
T=0.18;

A1=[-gamma 0 ; 0 0];
A2=[-gamma 1 ; -1 0];
B=[0;1];
K=[k1 k2 k3];
A1aux=[-gamma 0 0; 0 0 0; 1 0 0];
Baux=[0;1;-x1ref];
A2aux=[-gamma 1 0; -1 0 0; 1 0 0];

Xref=[x1ref;x2ref;0];

%X0=[x10;x20;x30];
X0=Xref;

aux1=[X0(1)];
aux2=[X0(2)];

s=K*(X0-Xref);
s1=K*(A1aux*X0+Baux);
s2=K*(A2aux*X0+Baux);
d(1)=((2*s+T*s2)/(s2-s1))/T
for i=2:N
s=K*(X0-Xref);
s1=K*(A1aux*X0+Baux);
s2=K*(A2aux*X0+Baux);
d1=((2*s+T*s2)/(s2-s1))/T;
d(i)=(d1-eta*d(i-1))/(1-eta); %%%control TDAS
X0(3)=[];
if 0<d(i) & d(i)<1
phi1=expm(A1*d(i)/2*T);
psi1=B*d(i)/2*T;
phi2=expm(A2*(T-d(i)*T));

psi2=A2\(expm(A2*(T-d(i)*T))-eye(2))*B;%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
X=phi1*phi2*phi1*X0+phi1*phi2*psi1+phi1*psi2+psi1;
X=[X;0];
elseif d(i)<=0
d(i)=0;
phi2=expm(A2*T);
psi2=A2\(expm(A2*T)-eye(2))*B;%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
X=phi2*X0+psi2;
X=[X;0];
elseif d(i)>=1
d(i)=1;
phi1=expm(A1*T);
psi1=B*T;
X=phi1*X0+psi1;
X=[X;0];
end

aux1=[aux1,X(1)];
aux2=[aux2,X(2)];

X0=X;
end
plot(aux1,aux2,'+r','markersize',2),ylabel('x_2')
hold on
i1=num2str(k1);
i2=num2str(k2);
i3=num2str(k3);
i4=num2str(gamma);
xlabel({'x_1';'';['k_1=',i1,' , ','k_2=',i2,' , ','k_3=',i3]})
%%%%ploteo de cuadro de referencia
hold on
plot(x1ref*ones(1,100),linspace(0,x2ref),':k','markersize',2)
hold on
plot(linspace(0,x1ref),x2ref*ones(1,100),':k','markersize',2)
hold on
plot(linspace(0,x1ref),zeros(1,100),':k','markersize',2)
hold on
%X=Estabilidad1Paux(k1,k2,k3,T,gamma)
%
plot(X(1),X(2),'o')
F=[aux1(:,end);aux2(:,end)]
G=[aux1(:,end-1);aux2(:,end-1)]
figure(2)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%5
subplot(211)
plot(x1ref*ones(1,N),'r')
hold on
plot(aux1,'+','markersize',2),ylabel('x_1'),xlabel('Periodos')
hold on

i1=num2str(k1);
i2=num2str(k2);
i3=num2str(k3);
i4=num2str(gamma);
i5=num2str(eta);
subplot(212)
plot(x2ref*ones(1,N),'r')
hold on
plot(aux2,'+','markersize',2),ylabel(' x_2'),xlabel('Periodos')
xlabel({'Periodos';'';['k_1=',i1,' , ','k_2=',i2,' , ','k_3=',i3]})
figure(3)
plot(d,'+','markersize',2), ylabel('Ciclo de trabajo normalizado')
hold on
i1=num2str(k1);
i2=num2str(k2);
i3=num2str(k3);
i4=num2str(gamma);
i5=num2str(eta);
xlabel({'Periodos';'';['k_1=',i1,' , ','k_2=',i2,' , ','k_3=',i3,' , ','\eta
=',i5]})
f=1-(1/(x1ref));
plot(f*ones(1,N),'g')
hold of
endd=d(end)
X0=Estabilidad1P(k1,k2,k3,T,gamma,x1ref)%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%5
s=K*(X0-Xref);
s1=K*(A1aux*X0+Baux);
s2=K*(A2aux*X0+Baux);
d1=((2*s+T*s2)/(s2-s1))/T

function regulacion101Daro
clear all
N=3500;
rho1 =0.2782; rho2 = 0.2371; gamma = 0.1860; Vt
=0.0274;T=0.18;
x10=2.1;

x20=(gamma*(x10))/2 + ((2*gamma*rho1*(x10) 4*gamma*rho1*(x10)^2 - 2*gamma*rho2*(x10) +


gamma^2*rho1^2*(x10)^2 + gamma^2*rho2^2*(x10)^2 4*Vt*gamma*rho1*(x10) - 2*gamma^2*rho1*rho2*(x10)^2 +
1)^(1/2) - gamma*rho2*(x10) + 1)/(2*rho1)
%
% x1ref=2.1;
% x2ref= 2.4159;
x1ref=2.1;
x2ref= 2.4;
regulacion7=[];
regulacion71=[];
nregulacion7=[];
nregulacion71=[];
regulacion6=[];
regulacion61=[];
nregulacion6=[];
nregulacion61=[];
regulacion5=[];
regulacion51=[];
nregulacion5=[];
nregulacion51=[];
regulacion4=[];
regulacion41=[];
nregulacion4=[];
nregulacion41=[];
regulacion3=[];
regulacion31=[];
nregulacion3=[];
nregulacion31=[];

regulacion2=[];
regulacion21=[];
nregulacion2=[];
nregulacion21=[];
regulacion1=[];
regulacion11=[];
nregulacion1=[];
nregulacion11=[];
sinregulacion1=[];
sinregulacion11=[];
mejor1=[];
mejor11=[];
c7=0.07*x1ref;
c72=0.07*x2ref;
c6=0.06*x1ref;
c62=0.06*x2ref;
c5=0.05*x1ref;
c52=0.05*x2ref;
c4=0.04*x1ref;
c42=0.04*x2ref;
c3=0.03*x1ref;
c32=0.03*x2ref;
c2=0.02*x1ref;
c22=0.02*x2ref;
c1=0.01*x1ref;
c12=0.01*x2ref;
k1=linspace(-0.5,0.5,20);
k2=linspace(-0.5,0.5,20);

for i=1:length(k1)
for j=1:length(k2)
P=Poincare101(N,x10,x20,x1ref,k1(i),k2(j),gamma,T,rho1,rho2,Vt);
X=[P(1,:)];
Y=[P(2,:)];
X1=ones(1,length(X));
Y1=ones(1,length(Y));
if max(abs((X-x1ref*X1)))>c7 & max(abs((Y-x2ref*Y1)))>c72
sinregulacion1=[sinregulacion1,k1(i)];
sinregulacion11=[sinregulacion11,k2(j)];
else
mejor1=[mejor1,k1(i)];
mejor11=[mejor11,k2(j)];
end
if max(abs((X-x1ref*X1)))<c7 & max(abs((Y-x2ref*Y1)))<c72
regulacion7=[regulacion7,k1(i)];
regulacion71=[regulacion71,k2(j)];
else
nregulacion7=[nregulacion7,k1(i)];
nregulacion71=[nregulacion71,k2(j)];
end
if max(abs((X-x1ref*X1)))<c6 & max(abs((Y-x2ref*Y1)))<c62
regulacion6=[regulacion6,k1(i)];
regulacion61=[regulacion61,k2(j)];
else
nregulacion6=[nregulacion6,k1(i)];
nregulacion61=[nregulacion61,k2(j)];
end

if max(abs((X-x1ref*X1)))<c5 & max(abs((Y-x2ref*Y1)))<c52


regulacion5=[regulacion5,k1(i)];
regulacion51=[regulacion51,k2(j)];
else
nregulacion5=[nregulacion5,k1(i)];
nregulacion51=[nregulacion51,k2(j)];
end
if max(abs((X-x1ref*X1)))<c4 & max(abs((Y-x2ref*Y1)))<c42
regulacion4=[regulacion4,k1(i)];
regulacion41=[regulacion41,k2(j)];
else
nregulacion4=[nregulacion4,k1(i)];
nregulacion41=[nregulacion41,k2(j)];
end
if max(abs((X-x1ref*X1)))<c3 & max(abs((Y-x2ref*Y1)))<c32
regulacion3=[regulacion3,k1(i)];
regulacion31=[regulacion31,k2(j)];
else
nregulacion3=[nregulacion3,k1(i)];
nregulacion31=[nregulacion31,k2(j)];
end
if max(abs((X-x1ref*X1)))<c2 & max(abs((Y-x2ref*Y1)))<c22
regulacion2=[regulacion2,k1(i)];
regulacion21=[regulacion21,k2(j)];
else
nregulacion2=[nregulacion2,k1(i)];
nregulacion21=[nregulacion21,k2(j)];
end
if max(abs((X-x1ref*X1)))<c1 & max(abs((Y-x2ref*Y1)))<c12
regulacion1=[regulacion1,k1(i)];

regulacion11=[regulacion11,k2(j)];
else
nregulacion1=[nregulacion1,k1(i)];
nregulacion11=[nregulacion11,k2(j)];
end

end
waitbar(i/length(k1))
end
plot(regulacion7,regulacion71,'sb','markerface','b','markersize',2)
hold on
plot(regulacion6,regulacion61,'sg','markerface','g','markersize',2)
hold on
%
plot(regulacion5,regulacion51,'sc','markerface','c','markersize',2)
%
hold on
%
%
plot(regulacion4,regulacion41,'sm','markerface','m','markersize',2)
%
hold on
%
%
plot(regulacion3,regulacion31,'sk','markerface','k','markersize',2)
%
hold on
%
%
plot(regulacion2,regulacion21,'sy','markerface','y','markersize',2)
%
hold on
%
%
plot(regulacion1,regulacion11,'sr','markerface','r','markersize',2)
%
hold on
%

%
plot(sinregulacion1,sinregulacion11,'sw','markerface','w','markersiz
e',2)
%
hold on
function
XP=Poincare101(N,x10,x20,x1ref,k1,k2,gamma,T,rho1,rho2,Vt);
close all
x2ref=(gamma*x1ref)/2 + ((2*gamma*rho1*x1ref 4*gamma*rho1*x1ref^2 - 2*gamma*rho2*x1ref +
gamma^2*rho1^2*x1ref^2 + gamma^2*rho2^2*x1ref^2 4*Vt*gamma*rho1*x1ref - 2*gamma^2*rho1*rho2*x1ref^2 +
1)^(1/2) - gamma*rho2*x1ref + 1)/(2*rho1)
A1=[-gamma 0 ; 0 -rho1];
A2=[-gamma 1 ; -1 -rho2];
B1=[0;1];
B2=[0;1-Vt]
K=[k1 k2];
Xref=[x1ref;x2ref];
X0=[x10;x20];
XP=[];
for i=1:N
s=K*(X0-Xref);
s1=K*(A1*X0+B1);
s2=K*(A2*X0+B2);
d(i)=((2*s+T*s2)/(s2-s1))/T;
if 0<d(i) & d(i)<1
phi1=expm(A1*d(i)/2*T);
psi1=A1\(expm(A1*d(i)/2*T)-eye(2))*B1;

Y0=phi1*X0+psi1;
phi2=expm(A2*(T-d(i)*T));
psi2=A2\(expm(A2*(T-d(i)*T))-eye(2))*B2;
Z0=phi2*Y0+psi2;
X=phi1*Z0+psi1;
XP=[XP,X];
elseif d(i)<=0
d(i)=0;
phi2=expm(A2*T);
psi2=A2\(expm(A2*T)-eye(2))*B2;
X=phi2*X0+psi2;
XP=[XP,X];
elseif d(i)>=1
d(i)=1;
phi1=expm(A1*T);
psi1=A1\(expm(A1*T)-eye(2))*B1;
X=phi1*X0+psi1;
XP=[XP,X];
end

X0=X ;
end
XP(:,1:length(XP)-100)=[];

You might also like