**Use MATLAB to do this problem**

## Expert Answer

**Here is the solution of the given algorithm on the basis of given criteria:-**L1=4;% length of first armL2=3;% length of second armx=6;% given values of xco-ordinates

y=2;% given values of y co-ordinates

%* The values of theta1 and theta2 are deduced mathematically from the x and y coordinates by using inverse kinematics formulae. *%c2 = (x.^2 + y.^2 - L1^2 - L2^2)/(2*L1*L2); s2 = sqrt(1 - c2.^2); theta2=atan2(s2,c2);% theta2 is deduced in degrees

k1 = L1 + L2.*c2; k2 = L2*s2; theta1D = atan2(y,x) - atan2(k2,k1);% theta1 is deduced in degrees

**theta1D**

**theta2**

Please run these commands into your MATLAB window and check out the output.

**Here is the output shown below:-**

=========================================================

**Part B:-**

**L1=4;** % length of first arm

**L2=3;** % length of second arm

**x=6;** % fixed values of x co-ordinates

**y=0.1:2:3.6;** % given values of y co-ordinates

%* The values of theta1 and theta2 are deduced mathematically from the x and y coordinates by using inverse kinematics formulae. *%

**c2 = (x.^2 + y.^2 – L1^2 – L2^2)/(2*L1*L2);
s2 = sqrt(1 – c2.^2);
theta2=atan2(s2,c2); % theta2 is deduced in degrees**

**k1 = L1 + L2.*c2;
k2 = L2*s2;
theta1D = atan2(y,x) – atan2(k2,k1);** % theta1 is deduced in degrees

**subplot(2,1,1);**

plot(theta1D);

ylabel(‘THETA1D’,’fontsize’,8)

title(‘Deduced theta1′,’fontsize’,8)

plot(theta1D);

ylabel(‘THETA1D’,’fontsize’,8)

title(‘Deduced theta1′,’fontsize’,8)

**subplot(2,1,2);
plot(theta2);
ylabel(‘THETA2D’,’fontsize’,8)
title(‘Deduced theta2′,’fontsize’,8)**

Here is the output shown below:-