Question

Write a Matlab to animate the motion of Grashof 4-bar mechanism (s+l < p+q); s =...

Write a Matlab to animate the motion of Grashof 4-bar mechanism (s+l < p+q); s = 5 cm, l =

13 cm, p = 10 cm, q = 10 cm

Homework Answers

Answer #1

function fourbar(r1,r2,r3,r4)
% fourbar simulates the kinematics of a four-bar linkage.
%
% fourbar(r1,r2,r3,r4) simulates the trajectories of a four-bar likanges of
% dimensions r1 (ground), r2 (driver), r3 (couples), and r4 (follower).
%
%
% Example
% fourbar(2,1,3,3.5)
%
% input arguments
if nargin < 4
r1 = 2;
r2 = 1;
r3 = 3;
r4 = 3.5;
end
s = min([r1 r2 r3 r4]);
l = max([r1 r2 r3 r4]);
if (s+l)>(sum([r1 r2 r3 r4])-(s+l))
disp('Not a Grashoff mechanism.')
return
end

% user-defind orientation of the ground
t1 = 0;
% user-defind delta of the angle of the driver
deltat2 = 2.5;
% loop for Theta2 (angle of the driver)
for t2 = 0:deltat2:360
% Finding Theta 4 (angle of the follower)
A = 2*r1*r4*cosd(t1) - 2*r2*r4*cosd(t2);
B = 2*r1*r4*sind(t1) - 2*r2*r4*sind(t2);
C = r1^2+r2^2+r4^2-r3^2-2*r1*r2*(cosd(t1)*cosd(t2)+sind(t1)*sind(t2));
% Assembly mode
s = -1;
t = (-B+s*sqrt(B^2-C^2+A^2))/(C-A);
t4 = 2*atand(t);
% Finding Theta 3 (angle of the coupler)
t3 = atan2((r1*sind(t1)+r4*sind(t4)-r2*sind(t2)),...
(r1*cosd(t1)+r4*cosd(t4)-r2*cosd(t2)))*180/pi;
  
% Position vectors
R1 = r1*[cosd(t1), sind(t1)];
R2 = r2*[cosd(t2), sind(t2)];
R3 = r3*[cosd(t3), sind(t3)];
R4 = r4*[cosd(t4), sind(t4)];

% Connections
O = [0,0]; % ground-driver
Q = O+R2; % driver-coupler
P = O+R2+R3; % coupler-follower
PP = O+R1+R4; % follower-coupler
R = O+R1; % ground-follower
  
if norm(P-PP) > 1e-1
disp('the closure equation is not satisfied')
else
% feel free to comment anything you don't need to plot
hold on
% Plot connections
plot(O(1),O(2),'co') % ground-driver
plot(Q(1),Q(2),'co') % driver-coupler
plot(P(1),P(2),'c.') % coupler-follower
plot(PP(1),PP(2),'co') % follower-coupler
plot(R(1),R(2),'co') % ground-follower

  
% Links
plot([O(1),R(1)],[O(2),R(2)],'g-') % ground
plot([O(1),Q(1)],[O(2),Q(2)],'r-') % driver
plot([Q(1),P(1)],[Q(2),P(2)],'b-') % coupler
plot([R(1),PP(1)],[R(2),PP(2)],'y-')% follower
  
axis equal, hold off
  
pause(0.1)
end
end

Type fourbar(5,10,13,10) in Matlab command prompt

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
2. Let A = {p, q, r, s}, B = {k, l, m, n}, and C...
2. Let A = {p, q, r, s}, B = {k, l, m, n}, and C = {u, v, w}, Define f : A→B by f(p) = m, f(q) = k, f(r) = l, and f(s) = n, and define g : B→C by g(k) = v, g(l) = w, g(m) = u, and g(n) = w. Also define h : A→C by h = g ◦ f. (a) Write out the values of h. (b) Why is it that...
I) Use MATLAB to compute the determinants of the following two matrices.   (Use format rat) P                         &
I) Use MATLAB to compute the determinants of the following two matrices.   (Use format rat) P                                         Q 5 0 0 0 -1 -1 1 1 13 2 0 0 2 0 1 3 -6 4 -1 0 2 -1 1 2 10 0 3 -2 1 0 3 3 II) The determinant of P could be computed without MATLAB. What general fact could have been used to do this? III) Use MATLAB to compute the matrix R= PQ and also...
The reaction: 2P + Q → R has the following proposed mechanism: Step 1:    P + QS...
The reaction: 2P + Q → R has the following proposed mechanism: Step 1:    P + QS (fast equilibrium) Step 2:    S + Q → T Step 3:    T + P → R + QIf step 2 is the rate-determining step, then the rate of formation of R should equal:
Perfect competition in Q and L(Short Run), if P=200, Q=2L^(0.5)k^(0.25), w=10, r=10; Find values of Q,L...
Perfect competition in Q and L(Short Run), if P=200, Q=2L^(0.5)k^(0.25), w=10, r=10; Find values of Q,L and K.
1. A monopsonist has the production function Q=4⋅L and faces the following labor supply and product...
1. A monopsonist has the production function Q=4⋅L and faces the following labor supply and product demand equations respectively. W=2+0.05⋅L P=10−0.025⋅Q How much labor should the firm hire in order to maximize profits if they mark their price 300% above marginal cost? Answer is not 10 2. A monopsonist has the production function Q=4⋅L and faces the following labor supply and product demand equations respectively. W=2+0.05⋅L P=10−0.025⋅Q What wage rate should the firm pay in order to maximize profits if...
A monopsonist has the production function Q = 4 ⋅ L and faces the following labor...
A monopsonist has the production function Q = 4 ⋅ L and faces the following labor supply and product demand equations respectively. W = 2 + 0.05 ⋅ L P = 10 − 0.025 ⋅ Q How much labor should the firm hire in order to maximize profits if they mark their price 300% above marginal cost?
A 1.65 mol of an ideal gas (Cv=3R/2) at T=14.5 oC and P=0.2 bar undergoes the...
A 1.65 mol of an ideal gas (Cv=3R/2) at T=14.5 oC and P=0.2 bar undergoes the following two step process: first an isothermal expansion against a constant pressure of 0.1 bar until the volume is doubled; followed by a cooling to -35.6 oC at constant volume. Calculate the following thermodynamic quantities for the total process: 1) Work (w) for step 1. 2) Heat (Q) for step 1. 3) Change in internal energy (U) for step 1. 4) Change in enthalpy...
Write MATLAB code to create a 5x5 matrix A with 2's on the diagonal, and -1...
Write MATLAB code to create a 5x5 matrix A with 2's on the diagonal, and -1 on the super- and sub-diagonal. Then replace the (1,1) element of A with a 1. (Make your commands capable of handling an arbitary sized NxN matrix by first defining N=5, then using the variable N as the size in each of the commands.)
Write code to evaluate the polynomial at the point indicated by using Horner’s algorithm. p(x)=x^5−x^4−3x^3−5x^2+10 at...
Write code to evaluate the polynomial at the point indicated by using Horner’s algorithm. p(x)=x^5−x^4−3x^3−5x^2+10 at x=2 (use MATLAB to code and show the results.)
The motion of an electron is given by x(t)=pt3+qt2+r, with p = -1.6 m/s3 , q...
The motion of an electron is given by x(t)=pt3+qt2+r, with p = -1.6 m/s3 , q = +1.3 m/s2 , and r = +9.0 m. Determine its velocity at t = 0. Determine its velocity at t = 1 s. Determine its velocity at t = 2 s. Determine its velocity at t = 3 s.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT