348 B Programs of Chapter 3: Velocity and Acceleration Analysis
aBn = double(subs(aB,slist,nlist));
fprintf(’aB1 = aB2 = [ %g, %g, %g ] (m/sˆ2)\n’, aBn)
fprintf(’|aB1| = |aB2| = %g (m/sˆ2)\n’, norm(aBn))
fprintf(’\n’)
xB = sym(’xB(t)’); % xB(t) symbolic
yB = sym(’yB(t)’); % yB(t) symbolic
% list for the symbolical variables of B
% xB’’(t), yB’’(t), xB’(t), yB’(t), xB(t), yB(t)
sB={diff(’xB(t)’,t,2),diff(’yB(t)’,t,2),...
diff(’xB(t)’,t),diff(’yB(t)’,t),’xB(t)’,’yB(t)’};
% three dots (...)
% are used whenever a line break is needed
% list for the numerical values of the sB list
nB={aBn(1),aBn(2),vBn(1),vBn(2),xBn,yBn};
% angular velocity and acceleration of links 2 and 3
phi3 = atan((yB-yC)/(xB-xC));
phi3n = subs(phi3,sB,nB);
fprintf(’phi2 = phi3 = %g (degrees)\n’,...
double(phi3n
*
180/pi))
dphi3 = diff(phi3,t);
dphi3n = subs(dphi3,sB,nB);
fprintf(’omega2 = omega3 = %g (rad/s) \n’,...
double(dphi3n))
ddphi3 = diff(dphi3,t);
ddphi3n = subs(ddphi3,sB,nB) ;
fprintf(’alpha2 = alpha3 = %g (rad/sˆ2) \n’,...
double(ddphi3n))
fprintf(’\n’)
xD = eval(xC + CD
*
cos(phi3n));
yD = eval(yC + CD
*
sin(phi3n));
plot([xA,xBn],[yA,yBn],’r’,[xC,xD],[yC,yD],’b’),
text(xA,yA,’ A’), text(xBn,yBn,’ B’),...
text(xC,yC,’ C’), text(xD,yD,’ D’), ...
axis([-0.05 0.3 -0.05 0.3])
% end of program
Results:
rB = [ 0.0707107, 0.170711,0](m)
vB1 = vB2 = [ -0.222144, 0.222144, 0 ] (m/s)