Asked by Wang
Write a matlab code for a hoekens linkage that will draw a 15 cm straight line.
clear % clears all variables from the workspace
clc % clears the command window and homes the cursor
close all % closes all the open figure windows
L0 = 7.5;
L1 = 3.75;
L2 = 9.375;
L3 = 9.375;
input_theta = 0:2:360; % input angle vector
% preallocate 1 3-D matrix for the atlas. Plot atlas of points with N
% spans of the coupler. The third index of the matrix is the point.
% Each column is a pair of x-y coordinate of the point
% And each column corresponds to one input angle
atlas = zeros(2,length(input_theta));
% Position of joint A (origin)
xA = 0; yA = 0;
% Position of joint D
xD = L0; yD = 0;
figure;
for ii = 1: length(input_theta)
theta1 = input_theta(ii)*pi/180;% convert angle to radians
% Position of joint B - position of the driver link
xB = xA + L1*cos(theta1);
yB = yA + L1*sin(theta1);
% Distance formula: BC=constant
eqnC2 = '(xB - xCsol )^2 + ( yB - yCsol )^2 = L2^2';
eqnC3 = '(xD - xCsol )^2 + ( yD - yCsol )^2 = L3^2';
% Solve the above equation
solC = solve(eqnC2, eqnC3,'xCsol','yCsol');
% Two solutions for xC and yC.
% Calculate steps of coordinates between B and C.
xC_sol = real(eval(solC.xCsol(1)));
yC_sol = real(eval(solC.yCsol(1)));
x_step = (xC_sol - xB)/2;
y_step = (yC_sol - yB)/2;
atlas(:,ii) = [xB+x_step;yB+y_step];
plot (xA, yA, 'r.',...
[xA, xB],[yA,yB],'g.-',...
[xB, xC_sol],[yB, yC_sol],'r.-',...
[xD, xC_sol],[yD, yC_sol],'b.-',...
'LineWidth', 4, 'MarkerSize', 25);
hold on
plot(atlas(1,1:ii),atlas(2,1:ii));
axis ([-10, 45,-10,35]),axis square;
grid
title(['\theta_1 = ', num2str(input_theta(ii)),' (deg)']);
hold off
pause (0.001)
end
clear % clears all variables from the workspace
clc % clears the command window and homes the cursor
close all % closes all the open figure windows
L0 = 7.5;
L1 = 3.75;
L2 = 9.375;
L3 = 9.375;
input_theta = 0:2:360; % input angle vector
% preallocate 1 3-D matrix for the atlas. Plot atlas of points with N
% spans of the coupler. The third index of the matrix is the point.
% Each column is a pair of x-y coordinate of the point
% And each column corresponds to one input angle
atlas = zeros(2,length(input_theta));
% Position of joint A (origin)
xA = 0; yA = 0;
% Position of joint D
xD = L0; yD = 0;
figure;
for ii = 1: length(input_theta)
theta1 = input_theta(ii)*pi/180;% convert angle to radians
% Position of joint B - position of the driver link
xB = xA + L1*cos(theta1);
yB = yA + L1*sin(theta1);
% Distance formula: BC=constant
eqnC2 = '(xB - xCsol )^2 + ( yB - yCsol )^2 = L2^2';
eqnC3 = '(xD - xCsol )^2 + ( yD - yCsol )^2 = L3^2';
% Solve the above equation
solC = solve(eqnC2, eqnC3,'xCsol','yCsol');
% Two solutions for xC and yC.
% Calculate steps of coordinates between B and C.
xC_sol = real(eval(solC.xCsol(1)));
yC_sol = real(eval(solC.yCsol(1)));
x_step = (xC_sol - xB)/2;
y_step = (yC_sol - yB)/2;
atlas(:,ii) = [xB+x_step;yB+y_step];
plot (xA, yA, 'r.',...
[xA, xB],[yA,yB],'g.-',...
[xB, xC_sol],[yB, yC_sol],'r.-',...
[xD, xC_sol],[yD, yC_sol],'b.-',...
'LineWidth', 4, 'MarkerSize', 25);
hold on
plot(atlas(1,1:ii),atlas(2,1:ii));
axis ([-10, 45,-10,35]),axis square;
grid
title(['\theta_1 = ', num2str(input_theta(ii)),' (deg)']);
hold off
pause (0.001)
end
Answers
Answered by
Wang
This code is for a four-bar linkage, but I don't know how to change it to hoekens linkage.
Point A and D are fixed, AD=Lo, crank is L1, coupler is actually L2=18.75, rocker is L3=9.375
Point A and D are fixed, AD=Lo, crank is L1, coupler is actually L2=18.75, rocker is L3=9.375
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.