You are on page 1of 3

SEBASTIÁN GIL MESA – DISEÑO DE MECANISMOS – TALLER MATLAB BARRAS

PRIMER PROGRAMA

function F = ejercicio1(X0)
global r2 r3 r4 r1y r1x
global th2
th3 = X0(1);
th4 = X0(2);
F(1) = r2*cos(th2) + r3*cos(th3) +
r4*cos(th4) - r1x*cos(0);
F(2) = r2*sin(th2) + r3*sin(th3) +
r4*sin(th4) - r1y*sin(270);
end

SEGUNDO PROGRAMA
clear all
close all
global r2 r3 r4 r1y r1x
global th2
r2 = 1.705;
r3 = 7.339;
r4 = 10.913;
r1y = 0.472;
r1x = 7.75;
numPos = 100;
TH2 = linspace(0,2*pi,numPos);
th3_inicial = deg2rad(341.27);
th4_inicial = deg2rad(115.66);
X0 = [th3_inicial, th4_inicial];
for n = 1:numPos
th2 = TH2(n);
G = fsolve('ejercicio1',X0);
th3 = G(1);
th4 = G(2);
X0 = G;
TH3(n) = th3;
TH4(n) = th4;
end
figure(1);
plot(rad2deg(TH2),rad2deg(TH3));
figure(2);
plot(rad2deg(TH2),rad2deg(TH4));
PRIMER PROGRAMA
function F = ejercicio2(X0)
global r2 r3 r4 r1y r1x
global th2
th3 = X0(1);
th4 = X0(2);
F(1) = r2*cos(th2) + r3*cos(th3) - r4*cos(th4) - r1x*cos(180);
F(2) = r2*sin(th2) + r3*sin(th3) - r4*sin(th4) - r1y*sin(270);
end
SEGUNDO PROGRAMA
clear all
close all
global r2 r3 r4 r1y r1x
global th2
r2 = 12;
r3 = 30;
r4 = 26;
r1y = 5;
r1x = 32;
numPos = 100;
TH2 = linspace(0,2*pi,numPos);
th3_inicial = deg2rad(215);
th4_inicial = deg2rad(293.9);
X0 = [th3_inicial, th4_inicial];
for n = 1:numPos
th2 = TH2(n);
G = fsolve('ejercicio2',X0);
th3 = G(1);
th4 = G(2);
X0 = G;
TH3(n) = th3;
TH4(n) = th4;
end
figure(1);
plot(rad2deg(TH2),rad2deg(TH3));
TH3Grados=rad2deg(TH3);
figure(2);
plot(rad2deg(TH2),rad2deg(TH4));

You might also like