clear all L0 = 0.4; L1 = 0.2; L2 = 0.4; L3 = 0.25; alfa = pi/4:pi/30:(4*pi+pi/4); X0 = [pi/6; 1.1*pi/2]; for j=1:length(alfa), %---- Método de Newton-Raphson ---- Nmax = 10; for i=1:Nmax, beta = X0(1); gama = X0(2); f = [L1*cos(alfa(j)) + L2*cos(beta) - L3*cos(gama) - L0; L1*sin(alfa(j)) + L2*sin(beta) - L3*sin(gama) ]; J = [-L2*sin(beta) L3*sin(gama); L2*cos(beta) -L3*cos(gama)]; X = X0 - J\f; X0 = X; end %---------------------------------- B(j) = X(1); G(j) = X(2); X0 = X; end for i=1:length(alfa) xB = L1*cos(alfa(i)); yB = L1*sin(alfa(i)); xC = L3*cos(G(i)); yC = L3*sin(G(i)); plot([0 xB],[0 yB],'b-') hold on plot([L0 L0+xC],[0 yC],'r-') plot([xB L0+xC],[yB yC],'g-') hold off axis([-1 1 -1 1]) pause(0.01) end