The results of the plots does not match the actual ones

3 次查看(过去 30 天)
Hello everyone,
I am trying to plot a simple kinematics function. I did it first in Excel and the plots were corrects however when I transfered problem into Matlab, I got different results. Below are the function, true plots from excel and results from the code:
The matlab code and the plots are shown below:
L_BC = 430; % mm
L_CA = 900; % mm
L_AA_prime = 100; % mm
theta_Anchor_range = deg2rad(linspace(127.2, 187.46, 1000));
L_AB = sqrt((L_AA_prime^2)+(L_BC^2)+(L_CA^2)+(2*L_BC*(L_CA*sin(theta_Anchor_range+pi)))-L_AA_prime*cos(pi+theta_Anchor_range));
L_Stroke = L_AB - 580;
figure;
plot(rad2deg(theta_Anchor_range), L_Stroke);
xlabel('Theta Anchor (degrees)');
ylabel('L_Stroke (mm)');
title('Variation of L_AB with Theta BC');
grid on;
theta_AB = atan((L_CA+(L_BC*sin(pi+theta_Anchor_range))./(L_BC*cos(pi+theta_Anchor_range)-L_AA_prime)));
figure;
plot(rad2deg(theta_Anchor_range), rad2deg(theta_AB));
xlabel('Theta BC (degrees)');
ylabel('Theta AB (deg)');
The variation of length have the same phenomena however it does not start from zero.
Your support is highly appreciated.

采纳的回答

Star Strider
Star Strider 2024-4-29
编辑:Star Strider 2024-4-29
There may have been a problem converting degrees to radian measure, however that is not required in MATLAB. Use trigonometric functions with the ‘d’ (sind, cosd, atan2d) to use degrees without having to convert them. Additionally, I use atan2d here, rather than atand. It seems to give the appropriate results.
Try this —
L_BC = 430; % mm
L_CA = 900; % mm
L_AA_prime = 100; % mm
theta_Anchor_range = linspace(127.2, 187.46, 1000);
L_AB = sqrt((L_AA_prime^2)+(L_BC^2)+(L_CA^2)+(2*L_BC*(L_CA*sind(theta_Anchor_range+180)))-L_AA_prime*cosd(theta_Anchor_range));
L_Stroke = L_AB - 580;
figure;
plot(theta_Anchor_range, L_Stroke);
xlabel('Theta Anchor (degrees)');
ylabel('L_Stroke (mm)');
title('Variation of L_AB with Theta BC');
grid on;
theta_AB = atan2d((L_CA+L_BC*sind(180+theta_Anchor_range)),(L_BC*cosd(180+theta_Anchor_range)-L_AA_prime));
figure;
plot(theta_Anchor_range, theta_AB);
grid
xlabel('Theta BC (degrees)');
ylabel('Theta AB (deg)');
% axis('equal')
EDIT — Corrected typographical errors.
.
  4 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import from MATLAB 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by