Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Curso:
Diseño de Mecanismos
Arequipa – Perú
2011
CODIGO MATLAB
clear all
clc
m=10;
k=100;
Xo=2;
Vo=2;
Wn=(k/m)^0.5;
n=0;
for p=0:700;
t=p*pi/180;
A1=Xo;
A2=Vo/Wn;
x=A1*cos(Wn*t)+A2*sin(Wn*t);
X=(((Vo/Wn)^2)+(Xo^2))^0.5;
T=atan(Wn*Xo/Vo);
x2=X*sin(Wn*t+T);
x3=X*cos((pi/2)-(Wn*t+T));
n=n+1;
sol(n,:)=[t,x,x2,x3];
end
%%
figure(1)
plot(sol(:,1),sol(:,2),sol(:,1),sol(:,3),sol(:,1),sol(:,4))
title('Posicion')
xlabel('Tiempo')
ylabel('X')
legend('Ecuacion 1', 'Ecuacion 2','Ecuacion 3')
grid on
axis square
Posicion
2.5
Ecuacion 1
2 Ecuacion 2
Ecuacion 3
1.5
0.5
0
X
-0.5
-1
-1.5
-2
-2.5
0 2 4 6 8 10 12 14
Tiempo
Figura 1
CODIGO CON ODE MATLAB
Ode1.M
function dXdt=ecdif(t,X)
dXdt=-k*X/m;
end
Ode2.M
t=0:700;
m=10;
k=100;
Xo=2;
Vo=2;
[tsol,X]=ode45(@ecdif,t,Xo)
plot(tsol,X)
title('DESPLAZAMIENTO')
xlabel('tiempo')
ylabel('X')
grid on
Figura 2