Fourbar Linkage Coupler Path

hey guys im writing to a code to demonstrate NON Grashof four bar triple rocker to plot the coupler curve of point P with respect to the global reference frame XY & the transmission angles vs input angles.Im not very good at matlab so if you could point out what i should understand that will be very helpful.
if true
%code
% // Note and symbols
% // R2 Input link // R1 ground link // R3 coupler link // R4 rocker
% // P coupler point // beta the coupler angle(Degrees)
% // RA,RB,RP,RPA position vector of the point A, B, P, point P refer to point A
% // input data for 4 bar linkage %
fprintf('\n');
L1 = input('input ground = ');
L2 = input('input link 2 = ');
L3 = input('input link 3 = ');
L4 = input('input link 4 = ');
fprintf('\n');
% // define point p position.
fprintf('\n');
PA = input('input link PA = ');
qpd = input('input point P (degree)= ');
fprintf('\n');
% // transfer 4 bar dimension
R1 = L1; R2 = L2; R3 = L3; R4 = L4; %qpd = 56.0;
beta=qpd
%cta = 14;
alpha = cta
q2=arccos(((a.^2+d.^2-b.^2-c.^2)/(2*a*d))- (b*c)/(a*d)))
%Define K
K1 = d/a
K4 = d/b
K5 = (c^2 - d^2 - a^2 - b^2) / (2*a*b)
%
D(q2) = cos(q2) - K1 + K4*cos(q2) + K5
E(q2) = -2*sin(q2)
F(q2) = K1 + (K4-1)*cos(q2) + K5
%
q31(q2) = 2*atand (( -E + sqrt(E^2 -4*D*F))/2*D)
q32(q2) = 2*atand (( -E - sqrt(E^2 -4*D*F))/2*D)
% // coupler position (P)
RA(q2) = a*(cos(q2) + j*sin(q2));
RPA(q2) = p*(cos(q3+beta) + j*sin(q3+beta));
RP = RA + RPA;
RPx(q2) = a*cos(q2)+p*cos(q3(q2)+beta); % position x of link P
RPy(q2) = a*sin(q2)+p*sin(q3(q2)+beta); % position y of link P
% Transform to the Global Frame
Xp(q2) = RPx(q2)*cos(alpha)-RPy(q2)*sin(alpha)
Yp(q2) = RPx(q2)*sin(alpha)+RPy(q2)*cos(alpha)
// plot path A, B and P
subplot(3,2,1);
plot(Ax,Ay, Bx,By, Px,Py) % path for A,B and P
title('linkage path motion')
legend('point A','point B','point P')
ylabel('y-axis')
xlabel('x-axis')
axis([xmin*1.5 xmax*1.5 ymin ymax])
daspect([1 1 1]) % fix plot ratio 1:1
set(legend,'color','none');
grid on
end
If you need the relevant problem statement please let me know.

3 件のコメント

John D'Errico
John D'Errico 2018 年 9 月 19 日
編集済み: John D'Errico 2018 年 9 月 19 日
But what is wrong with what you did? Why do YOU think there is a reason to even ask? Are you just asking someone to give your code a thorough read, guess what you want it to do, and then give you a complete critique on how you might have done it better? Sorry, but that makes little sense.
If the code works, does what you want it to do, in a reasonable amount of time for your task, then it is fine, at least for you. (For my tastes, it has many hallmarks of code written by a novice. I.e., a script, with lines not terminated by semi-colons. An interface dominated by input statements. Use of variables like alpha and beta, which just happen to be functions already in use in MATLAB, so it may prevents them from working properly in some instances. Other issues that may be serious are the mixed use of trig functions in degrees AND radians. Can you recognize an invitation for bugs? But so what? It is your code, that does apparently what you want it to do.)
As you use MATLAB more, you will learn better programming styles.
Alessandro Mingarelli
Alessandro Mingarelli 2021 年 4 月 14 日
Perché non può? Ha chiesto solo se fosse giusto e qualche consiglio per migliorare il codice...
Kerith Lumiares
Kerith Lumiares 2022 年 8 月 25 日
Can I have the relevant problem stament please. Thank you

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeNumerical Integration and Differential Equations についてさらに検索

質問済み:

2018 年 9 月 19 日

コメント済み:

2022 年 8 月 25 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by