Sunteți pe pagina 1din 3

manivela=input('Ingrese la longitud de la Manivela: ');

biela=input('Ingrese la longitud de la Biela: ');


dist=input('Ingrese la dist entre puntos: ');
vueltas=input('Ingrese el numero de vueltas a representar,(mas de 2): ');
rpm = input('Ingrese la Velocidad Angular de la Manivela: ');
pregunta1=['Ingrese Incremento en fracci?n de grados'];
pregunta2=['Por ejemplo el valor puede ser 0.01, 0.02 , 0.03,'];
pregunta3=['0.04, 0.06, 0.09, 0.1, 0.2, 0.3, 0.4, 0.6, 0.9 finalmente 1:
'];
disp (pregunta1); disp (pregunta2); disp (pregunta3);
inc=input(' incremento:');
qd=rpm/10;
if biela > manivela
qg=0:1:(360*vueltas);
for i=1:(360*vueltas)+1;
q(i) = deg2rad(qg(i)); %PASAR DE CENA DEG
end
w=1/60;
x(1)=0; y(1)=0;
x2(1)=manivela; y2(1)=0;
x3(1)=manivela+biela; y3(1)=0;
x4(1)=dist; y4(1)=0;
x5=dist; y5(1)=0;
for i=1:(360*vueltas)-1
q2(i)=atan(-1*(manivela*sin(q(i)))/( dist-manivela*cos(q(i))));%ver arcos
q3(i)=q2(i)-180;
x2(i)=manivela*cos(q(i));%ECUACION 1
y2(i)=manivela*sin(q(i));%ECUACION 1
x3(i)=x2(i)+biela*cos(q2(i));%ECUACION 2
y3(i)=y2(i)+biela*sin(q2(i));
x4(i)=dist;
y4(i)=0;
%POSICION
posx(i)=x3(i);
posy(i)=y3(i);
end
figure(1);
for i=1:(360*vueltas)-1;
x(2)=x2(i); y(2)=y2(i);
x(3)=x3(i); y(3)=y3(i);
plot(x2(1:i),y2(1:i),'b','LineWidth',2);
title 'Movimiento del sistema'
xlabel ('Posicion X')
ylabel ('Posicion Y')
hold on
plot(x4,y4,'*')
plot(x,y,'r','LineWidth',3);
plot(x3(1:i),y3(1:i),'g','LineWidth',2);
axis equal;
axis([-manivela,biela+manivela,-manivela,manivela]);
hold off
pause(0.01);
end

else
error('Mecanismo Ilicito porque la biela no puede ser mas corta que la
manivela')
end
%VELOCIDADES
rad=deg2rad(1);
deltat=rad/qd;
max=0;
grado=0;
for i=1:(360*vueltas)-2
Velx(i)=(posx(i+1)-posx(i))/(deltat);
Vely(i)=(posy(i+1)-posy(i))/(deltat);
VelT(i)=((Vely(i)*Vely(i))+(Velx(i)*Velx(i)))^0.5;
end
for i=1:(360*vueltas)-3
Acelx(i)=(Velx(i+1)-Velx(i))/(deltat);
Acely(i)=(Vely(i+1)-Vely(i))/(deltat);
AcelT(i)=((Acely(i)*Acely(i))+(Acelx(i)*Acelx(i)))^0.5;
if AcelT(i)> max
max=AcelT(i);
grado=i;
end
end
acelmax= max;
disp ('La Aceleracion maxima en cm/s^2 es:')
disp (acelmax)
disp ('y se alcanza a los')
disp (grado)
disp ('grados')
figure(2)
t=[0:deltat:((360*vueltas)-2)*deltat];
t1=[0:deltat:((360*vueltas)-3)*deltat];
t2=[0:deltat:((360*vueltas)-4)*deltat];
subplot(3,1,1)
plot(t, posx,'g','LineWidth',2)
title 'Posicion/Velocidad/Aceleracion'
xlabel('tiempo(seg)')
ylabel('Pos X (cm)')
subplot(3,1,2)
plot(t1,Velx,'r','LineWidth',2)
xlabel('tiempo(seg)')
ylabel('Vel X (cm/seg)')
subplot(3,1,3)
plot(t2,Acelx,'b','LineWidth',2)
xlabel('tiempo(seg)')
ylabel('Acel X (cm/seg^2)')
figure(3)
subplot(3,1,1)
plot(t, posy,'g','LineWidth',2)

title 'Posicion/Velocidad/Aceleracion'
xlabel('tiempo(seg)')
ylabel('Pos Y (cm)')
subplot(3,1,2)
plot(t1,Vely,'r','LineWidth',2)
xlabel('tiempo(seg)')
ylabel('Vel Y (cm/seg)')
subplot(3,1,3)
plot(t2,Acely,'b','LineWidth',2)
xlabel('tiempo(seg)')
ylabel('Acel Y (cm/seg^2)')
figure(4)
t=[0:deltat:((360*vueltas)-2)*deltat];
t1=[0:deltat:((360*vueltas)-3)*deltat];
t2=[0:deltat:((360*vueltas)-4)*deltat];
subplot(2,1,1)
plot(t1,VelT,'r','LineWidth',2)
title 'Velocidad y Aceleracion Total'
xlabel('tiempo(seg)')
ylabel('Vel (cm/seg)')
subplot(2,1,2)
plot(t2,AcelT,'b','LineWidth',2)
xlabel('tiempo(seg)')
ylabel('Acel (cm/seg^2)')

S-ar putea să vă placă și