4. Matlab Problem 25 Extend the Matlab code below to include velocity and acceleration analysis using kinematic coefficients. Use link lengths r=6, r=2, r=5, r4=4. Plot all kinematic coefficients and output angular velocities and accelerations versus input angle. Assume constant input speed of I rad/sec.
1- clear
2- th1=0
r1=4
r2=3
r3=5
r4=4
S=3
3-
4- th3=88*pi/180
th4=108*pi/180;
5- for i=1:173,
input rotation input speed2 and acceleration a2
Init il guess for the engn angles
This loop creates input rotation f s.5.degree increment
8-
9-
10
11-
12
13
14-
15-
16
17.
18-
19
20
21
22-
23-
24
25-
26
27- count=
etall c
itiong to tnue (1) so that while loop executes the first time while condition condition2 V check the size of N correction against a tolerance. In this case .eol rad T1=r2*cos(th2)+r3-cos(th3)-r4*cos(th4)-r1; the x and y scalar equations are 12=r2*sin(th2)+r3*sin(th3)-r4*sin(th4); defined as functions that must be made equal to zero (1-f1 vector f 15 the right hand side vector set to the 1(2-12
a(1,1)=r1*sin(th3)
a(1,2)=r4*sin(th4)
on the estimates of th3 and tht A2,1=r3*cos(th3)
A(2,2)=r4*cos(th4); del=A\f solve for the corrections this is a matrix equation of the form dth=del' v A x =f where x represents the needed corrections. In this program we use del, 2 by 1 matrix to hold the corrections. The output angles are corrected, and the process is repeated within the while loop until the convergence is achieved. count counter to avoid infinite loop
29 -
30
31
32
e can examine the following logical statements conditionl pertains to correction on angles. condition2 is the values of 1 ang +2 and codit3 is whether the number of iterations 1 condition1=abs(dth1)>0.0011 abs(dth(2)>0.001
37-
38
39 -
40 -
41-
42 -
43
44 -
45
condition2
count=28
end
21=th2*180/pi
t41=th4-180/pi
ct1=count;
end