Documentos de Académico
Documentos de Profesional
Documentos de Cultura
AREQUIPA PERU
2018
*Primero tenemos que tener nuestro modelo que simularemos, en este caso será de manera de
ejemplo un sistema masa-resorte. Las siguientes ecuaciones definen dicho modelo y sistema:
𝑥 = 𝑓(𝑥, 𝑢)
𝑥̇ 1 = 𝑥2
{ ... (1)
𝑥̇ 2 = 𝑎 ∗ 𝑥1 + 𝑏 ∗ 𝑥2 + 𝑢
𝐽 ∗ 𝜃̈ = −𝑏 ∗ 𝜃̇ − K ∗ 𝜃̇ + 𝜏
𝑏 K 𝜏
𝜃̈ = −( 𝐽 ) ∗ 𝜃̇ − ( J ) ∗ 𝜃 + (𝐽) … (2)
𝑥̇ 1 = 𝑥2
(2) en (1 ) → Dinámica del sistema { 𝑏 K 𝜏 … (3)
𝑥̇ 2 = −( ) ∗ 𝜃̇ − ( ) ∗ 𝜃 + ( )
𝐽 J 𝐽
Donde:
𝑥2 → 𝜃
𝑥1 → 𝜃̇
*Segundo debemos colocar estas ecuaciones en el editor de Scilab y guardarlo como una función
para luego ser usado por Xcos. El archivo es guardado es modelo_pitch.sci
modelo_pitch.sci
function [xdot]=modelo_pitch(x1, x2, u)
xdot=[x2;-x1-x2+u];
endfunction
MATLAB
masa_resorte.m
end
*Creamos otro archivo.m en Matlab que presenta el algoritmo de Runge-Kutta que está
vinculado con nuestro sistema dinámico, llamando a la función masa_resorte para los valores
de k1, k2, k3, k4.
runge.m
function [resp,t]=runge(ta,tb,h,xzero,uzero)
% ta = tiempo inicial
% tb = tiempo final
% h = Paso del tiempo
% n = Numero de iteraciones
n=(tb-ta)/h;
resp=xzero;
xant=xzero;
i=1;
t(i)=ta;
while i<=n
k1=masa_resorte(xant,uzero);
k2=masa_resorte(xant+(0.5*h)*k1,uzero);
k3=masa_resorte(xant+(0.5*h)*k2,uzero);
k4=masa_resorte(xant+(0.5*h)*k3,uzero);
xx=xant+(h/6)*(k1+2*k2+2*k3+k4);
i=i+1;
t(i)=ta+(i-1)*h;
xant=xx
aa(:,1)=xzero;
aa(:,i)=xx;
t(1,i)=t(i);
resp=[aa];
end
figure
subplot(2,2,1)
plot(t,resp(1,:))
title('x1dot vs tiempo')
xlabel('tiempo')
ylabel('x1dot1')
subplot(2,2,2)
plot(t,resp(2,:))
title('x2dot vs tiempo')
xlabel('tiempo')
ylabel('x2dot')
subplot(2,2,3)
plot(t,resp)
title('xdot vs tiempo')
xlabel('tiempo')
ylabel('x2dot')
legend('x1dot','x2dot')
end
>>
[resp,t]=runge(ta,tb,h,xzero,uzero)
masa_resorte.sci
function [xdot]=masa_resorte(x, u)
x1=x(1);
x2=x(2);
ui=u;
// parametros del modelo
k=1;
m=1;
b=1;
xdot=[x2;-(k/m)*x1-(b/m)*x2-(1/m)*ui];
endfunction
*Creamos otro archivo.m en Scilab que presenta el algoritmo de Runge-Kutta que está
vinculado con nuestro sistema dinámico, llamando a la función masa_resorte para los valores
de k1, k2, k3, k4.
runge1.sci
while i<=n
k1=masa_resorte(xant,uzero);
k2=masa_resorte(xant+(0.5*h)*k1,uzero);
k3=masa_resorte(xant+(0.5*h)*k2,uzero);
k4=masa_resorte(xant+(0.5*h)*k3,uzero);
xx=xant+(h/6)*(k1+2*k2+2*k3+k4);
i=i+1;
xant=xx
aa(:,1)=xzero;
aa(:,i)=xx;
t(1,i)=ta+(i-1)*h;
resp=[aa];
end
subplot(2,2,1)
plot(t,resp(1,:))
title("x1dot vs tiempo")
xlabel("tiempo")
ylabel("x1dot1")
subplot(2,2,2)
plot(t,resp(2,:))
title("x2dot vs tiempo")
xlabel("tiempo")
ylabel("x2dot")
subplot(2,2,3)
plot(t,resp)
title("xdot vs tiempo")
xlabel("tiempo")
ylabel("x2dot")
legend("x1dot","x2dot")
endfunction
>> [resp,t]=runge1(ta,tb,h,xzero,uzero)
4.- Backstepping
𝑥̇ 1 = 𝑎 ∗ 𝑥1 2 + 𝑥2
Sistema Dinámico { 𝑥̇ 2 = 𝑥3
𝑥̇ 3 = 𝑢
*Creamos nuestro archivo del edit de Scilab que contiene el sistema dinámico anterior.
modelo_pitch1.sci
*Creamos nuestro archivo del edit de Scilab que contiene la ley de control “u”.
ley_de_control.sci
//u=-6*(x1^4)-6*(x1^3)-4*(x1^2)-3*x1-2*(x1^2)*x2-6*x1*x2-2*x1*x3-2*(x2^2)-5*x2-3*x3
endfunction