Академический Документы
Профессиональный Документы
Культура Документы
Posicin
-Velocidad.
-Aceleracin.
-Jacobiano.
-Dibuja el Mecanismo.
%Dibuja el mecanismo
function DibujaMecanismo
global q;
%Limpia la pantalla
cla;
%Extrae los 3 puntos m_oviles del cuadril_atero
x1=q(1); y1=q(2); x2=q(3); y2=q(4);
x3=q(5); y3=q(6);
%Dibuja el tri_angulo del acoplador en rojo
fill([x1,x3,x2],[y1,y3,y2],'r');
%Dibuja tres barras m_oviles entre las cuatro articulaciones
line([0,x1,x2,2],[0,y1,y2,0],'lineWidth',3);
%Vacia el buffer de dibujo
drawnow;
end
-Main.
%Programa principal
%Limpia la memoria
clear;
%Inicializa variables q, qp (=q_prima) y qpp (=q_segunda)
global q qp qpp
q=zeros(7,1); qp=zeros(7,1); qpp=zeros(7,1);
%Valor inicial de las coordenadas x1, y1, x2, y2, x3, y3, ang
q(1)=1; q(2)=0; q(3)=3; q(4)=1; q(5)=1.5; q(6)=3; q(7)=0;
%Establece el n_umero de incrementos para 360o o 1 seg
numIncr=500;
%Inicializa las variables q(t), q_prima(t) y q_segunda(t)
q_t =zeros(7,numIncr+1);
qp_t =zeros(7,numIncr+1);
qpp_t =zeros(7,numIncr+1);
%Crea la figura que contendr_a la animaci_on
fig1=figure(1);
hold on;
axis([-2,5,-2,4]); %Establece los l__mites [xmin,xmax,ymin,ymax]
axis manual; %Congela los l__mites anteriores
axis off %Elimina el dibujo de los ejes
%Bucle de animaci_on
global angDato;
for i=0:numIncr
angDato=2*pi*(i/numIncr);
q = ProbPosicion;
qp = ProbVelocidad;
qpp = ProbAceleracion;
DibujaMecanismo;
%Almacena informaci_on
q_t (:,i+1)=q;
qp_t (:,i+1)=qp;
qpp_t(:,i+1)=qpp;
end
%Crea la figura con los plots del punto 3
fig2=figure(2);
%Plot de x3, y3
subplot(3,2,1); plot(q_t(7,:),q_t(5,:)); xlabel('\xi'); ylabel('x3');
subplot(3,2,2); plot(q_t(7,:),q_t(6,:)); xlabel('\xi'); ylabel('y3');
%Plot de x3_prima, y3_prima
subplot(3,2,3); plot(q_t(7,:),qp_t(5,:)); xlabel('\xi'); ylabel('xp3');
subplot(3,2,4); plot(q_t(7,:),qp_t(6,:)); xlabel('\xi'); ylabel('yp3');
%Plot de x3_segunda, y3_segunda
subplot(3,2,5); plot(q_t(7,:),qpp_t(5,:)); xlabel('\xi'); ylabel('xpp3');
subplot(3,2,6); plot(q_t(7,:),qpp_t(6,:)); xlabel('\xi'); ylabel('ypp3');
Resultados