How I can to resolve the code below?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function [x, y, z] = Forward_Kinematics1(theta1, theta2, theta3)
syms x y z
% kinematic parameters
R = 94.52;
L1 = 170;
L2 = 319.5;
r = 65;
% Calculate sine and cosine values
c1 = cosd(theta1); s1 = sind(theta1);
c2 = cosd(theta2); s2 = sind(theta2);
c3 = cosd(theta3); s3 = sind(theta3);
% define B1'
B1 = [0; -R - L1*c1 + r; L1*s1];
% define B2'
B2 = [(-sqrt(3)/2)*(-R-L1*c2+r); (-1/2)*(-R-L1*c2+r); L1*s2];
% define B3'
B3 = [(sqrt(3)/2)*(-R-L1*c3+r); (-1/2)*(-R-L1*c3+r); L1*s3];
% Define constants
a1 = 2*(B1(1) - B2(1)); a2 = 2*(B1(1) - B3(1));
b1 = 2*(B1(2) - B2(2)); b2 = 2*(B1(2) - B3(2));
c1 = 2*(B1(3) - B2(3)); c2 = 2*(B1(3) - B3(3));
d1 = (B2(1)^2 + B2(2)^2 + B2(3)^2) - (B1(1)^2 + B1(2)^2 + B1(3)^2);
d2 = (B3(1)^2 + B3(2)^2 + B3(3)^2) - (B1(1)^2 + B1(2)^2 + B1(3)^2);
% Define coefficients for z
A = 1;
B = -2*B1(3);
C = B1(3)^2 - L2^2 + (B1(1))^2 + (B1(2))^2;
% Define equations as symbolic expressions
eq1 = a1 * x + b1 * y + c1 * z - d1;
eq2 = a2 * x + b2 * y + c2 * z + d2;
eq3 = A * z^2 + B * z + C;
2 commentaires
Réponses (1)
Sandeep Mishra
le 18 Sep 2024
Hi Ky,
I executed the code snippet in MATLAB R2022a and encountered the same error.
After investigating further, I came across a relevant MATLAB Answers post addressing a similar issue:
The root cause of the error is related to the ‘fsolve’ function, to resolve this, you can update the code snippet by passing the inputs in the following manner:
equations = matlabFunction([eq1; eq2; eq3], 'Vars', {[x; y; z]});
Please refer to the below MathWorks documentation to learn more about ‘fsolve’ function of MATLAB:
I hope this helps.
0 commentaires
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!