Documentos de Académico
Documentos de Profesional
Documentos de Cultura
close all
M = 0.5;
m = 0.3;
L = 0.5;
g = 9.8;
global epsilon l0 l1 l2 l3
epsilon = M/m;
disp('Los (cuatro) polos se colocan en s = -1')
l3 = 4;
l2 = 6;
l1 = 4;
l0 = 1;
roots([1 l3 l2 l1 l0])
function dy = f(y,t)
global epsilon l0 l1 l2 l3
x1 = y(1);
x2 = y(2);
th1 = y(3);
th2 = y(4);
v = -l3*(-th2)-l2*(-th1)-l1*(x2-th2)-l0*(x1-th1);
u = (1+epsilon)*(-th1)-epsilon*v;
dx = x2;
d2x = ((u-th2*th2*sin(th1))+cos(th1)*sin(th1))/(epsilon+sin(th1)*sin(th1));
dth = th2;
d2th = (cos(th1)*(u-th2*th2*sin(th1))+(1+epsilon)*sin(th1))/(epsilon+sin(th1)*sin(th1));
dy = [dx;d2x;dth;d2th];
end
# condiciones iniciales para la animacion, en coordenadas normalizadas
y0 = [2.0 0 0.1 0];
np = 1000;
ti = 0;
tf = 2*sqrt(g/L);
t = linspace(ti,tf,np);
y = lsode("f",y0,t);
set (0, "defaultlinelinewidth", 1.0, "defaulttextfontname", "Helvetica", "defaultaxesfontname", "Helvetica",
"defaultaxesfontsize", 12.0);
h = 0.1;
Carro = [-0.2 0.2 0.2 -0.2 -0.2;0 0 h h 0]
Base = [-1 1;0 0]
Pendulo = [0 0;0 L]
figure
c = 1;
for n = 1:40:np,
plot(Carro(1,:)+y(n,1)*L,Carro(2,:),'k')
hold on
G = [cos(y(n,3)) -sin(y(n,3)); sin(y(n,3)) cos(y(n,3))];
NPendulo = G*Pendulo;
plot(NPendulo(1,:)+y(n,1)*L,NPendulo(2,:)+h,'r')
plot(Base(1,:),Base(2,:),'b')
axis([-1.5 1.5 -0.5 1])
axis equal
print (sprintf("out/%05d.png", c), "-S640,480")
clf
c ++
end
Este interesante ejemplo es parte del material adicional de nuestro nuevo texto Control
por linealización.