Clear Filters
Clear Filters

The results of the plots does not match the actual ones

3 views (last 30 days)
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.

Accepted Answer

Star Strider
Star Strider on 29 Apr 2024
Edited: Star Strider on 29 Apr 2024
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 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!