Question

4 A four-bar linkage system is shown above. The first link, a, is an input link (crank) of length 1. The second link, b, is a

[MATLAB Coding] A four-bar linkage system is shown above. The first link, a, is an input link (crank) of length 1. The second link, b, is a coupler link of length 2. The third link, c, is an output link of length 4. The forth link, d, is the fixed link (ground) of length 5. All lengths are provided in metres. Please answer the whole question in MATLAB coding.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

function [root,iter,absdiff] = modifiedSecantMethod(f,x0,dx,tol)

iter = 1;
xn = x0;

while true
  
Xn = xn - dx*f(xn)/(f(xn+dx)-f(xn)); %computing root
  
absdiff(iter) = abs(f(Xn)-0); % get the absolute difference
  
%termination
if absdiff(iter)<tol
root = Xn;
root = root*180/pi; % to degrees
break;
end

xn = Xn;
iter = iter+1;
end

end

------------------------------------------------------------------------------


function [root,iter,absdiff] = falsePositionMethod(f,x0,x1,tol)

a = x0;
b = x1;

if ~(f(a)*f(b)<0)
error('ERROR: f(a)*f(b) must be less than 0')
end
iter = 1;
while true
x = (a *f(b) - b*f(a))/(f(b)-f(a)); %computing the root
  
absdiff(iter) = abs(f(x)-0); %getting absolute difference
  
if absdiff(iter)<=tol %termination
break;
elseif f(a)*f(x)>=0
a = x;
elseif f(b)*f(x)>=0
b = x;
end
iter = iter+1;   
end
root = x;
root = root*180/pi; % to degrees
end

-------------------------------------------------------------------------------

function [root,iter,absdiff] = bisectionMethod(f,x_pos,x_neg,tol)

iter = 1;

while true
x_mid = (x_pos+x_neg)/2; %computing the root
if f(x_mid)<0
x_neg = x_mid;
else
x_pos = x_mid;
end

absdiff(iter) = abs(f(x_mid)-0); %getting absolute differences
  
  
if absdiff(iter)<tol %termination
break;
end
  
x_mid = (x_pos+x_neg)/2;
iter = iter+1;
end


root = x_mid;

root = root*180/pi; % to degrees
end

-----------------------------------------------------------------------------------------


%driver file

clear
clc
close all

xl = 120; xu = 165; xi = 120; %degrees
xl = xl*pi/180; xu = xu*pi/180; xi = xi*pi/180; %to radians

pert = 0.01; precision = 1e-4;
a = 1; b=2;c=4;d=5; %meters

%let x2 = theta2 and x4 = theta4

x2 = 30;%degrees
x2 = x2*pi/180; %to radians

f = @(x4) (d/a).*cos(x4) - (d/c)*cos(x2) + ((a^2-b^2+c^2+d^2)/(2*a*c)) - cos(x2-x4);


%using fzero
fprintf('\nFZERO')
root = fzero(f,[xl,xu]); %radians
root = root*180/pi; %to degrees
fprintf(['\nRoot: ' num2str(root) ' degrees'])

methods = {'modified secant','false position','bisection'};

%modified secant
fprintf('\n\nMODIFIED SECANT')
[root1,iters1,absdiff1] = modifiedSecantMethod(f,xi,pert,precision);
fprintf(['\nRoot: ' num2str(root1) ' degrees'])
fprintf(['\niterations: ' num2str(iters1)])


%false position
fprintf('\n\nFALSE POSITION')
[root2,iters2,absdiff2] = falsePositionMethod(f,xl,xu,precision);
fprintf(['\nRoot: ' num2str(root2) ' degrees'])
fprintf(['\niterations: ' num2str(iters2)])


% bisection
fprintf('\n\nBISECTION')
[root3,iters3,absdiff3] = bisectionMethod(f,xl,xu,precision);
fprintf(['\nRoot: ' num2str(root3) ' degrees'])
fprintf(['\niterations: ' num2str(iters3)])

%method requiring least amount of iterations
iters = [iters1 iters2 iters3];
minIterIndex = find(iters==min(iters));
methodLeastIters = methods{minIterIndex};
fprintf(['\n\nMethod requiring least amount of iterations: ' methodLeastIters '\n\n']);


%plotting convergence
figure
plot(1:iters1,absdiff1,'-o r')
hold on
plot(1:iters2,absdiff2,'-o g')
hold on
plot(1:iters3,absdiff3,'-o b')
title('convergence')
xlabel('iteration')
ylabel('|f(x)-0|')
legend('modified secant','false position','bisection')

%OUTPUT

FZERO Root: 144.8347 degrees MODIFIED SECANT Root: 144.836 degrees iterations: 3 FALSE POSITION Root: 144.8356 degrees iterat

convergence 0.3 _ modified secant - false position 0.25 ebisection 0.2 0.15 0.1 0.05 0 12 4 6 8 10 14 iteration

COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,

IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~

Add a comment
Know the answer?
Add Answer to:
[MATLAB Coding] A four-bar linkage system is shown above. The first link, a, is an input link (crank) of length 1. The second link, b, is a coupler link of length 2. The third link, c, is an output l...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Pl. (50pts) The four-bar linkage in the posture shown is driven by crank 2 at (02-25rpm cew. Dete...

    Pl. (50pts) The four-bar linkage in the posture shown is driven by crank 2 at (02-25rpm cew. Determine: I) Angular velocities of link 3 2) Angular velocities of link 4 3) Velocity of point P 0.356 0.950 / 0.785 0.544 o: VBA 43 VA 02 04 Pl. (50pts) The four-bar linkage in the posture shown is driven by crank 2 at (02-25rpm cew. Determine: I) Angular velocities of link 3 2) Angular velocities of link 4 3) Velocity of point...

  • 2. (50 points) The link lengths of a linkage, shown in Figure 2 (not to scale), are L- 5" (ground...

    Kinematics please answer asap with clear work 2. (50 points) The link lengths of a linkage, shown in Figure 2 (not to scale), are L- 5" (ground), and 2-1" (input), L3 3.5" (coupler), L-3" (output or follower), respectively. The location of the coupler point P is given as RPA-4", and δ,-20° When the input link is at 6-55°, we have a-31.251° and θ4-1 18.561° for the open configuration. (a) Find the corresponding transmission angle at this configuration and the corresponding...

  • Q3. 1 Figure Q3 For the four bar linkage shown in Figure Q3, assume the diagram...

    Q3. 1 Figure Q3 For the four bar linkage shown in Figure Q3, assume the diagram is drawn to scale and that crank link 2 has a length of 0.2m and an angular velocity of 20rad/s clockwise driven by an input torque of 5Nm. a) Find the positions with respect to the crank origin at A of the instant centre of velocity between the coupler link 3 and the ground link 1 and between the crank link 2 and the...

  • Find the solution of Problem 2.8 using Newton-Raphson method with the starting value of as 90...

    Find the solution of Problem 2.8 using Newton-Raphson method with the starting value of as 90 degrees and =0.001 Please upload the program using VBA or Matlab w a stress of o; = 55 x 103 psi, when M = 5 lb-in and d = 0.1 in. 2.8. The angular position of the output link (04) of a four-bar linkage corresponding to any specified angular position of the input link (02) can be computed using the Freudenstein's equation [2.6] kı...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT