The results of the plots does not match the actual ones
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Abdulrahman Alhassan
el 29 de Abr. de 2024
Comentada: Star Strider
el 29 de Abr. de 2024
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:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1682351/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1682351/image.jpeg)
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)');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1682356/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1682361/image.jpeg)
The variation of length have the same phenomena however it does not start from zero.
Your support is highly appreciated.
0 comentarios
Respuesta aceptada
Star Strider
el 29 de Abr. de 2024
Editada: Star Strider
el 29 de Abr. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!