Matlab solve error : "Solutions are parametrised by the symbols...unable to convert into double"

119 visualizaciones (últimos 30 días)
I am trying to solve the following system of equations
syms a_t1
syms a_t2 positive
syms a_a
for i = 1 : length(Alpha_r)
% System vec(VR) = vec(V'R')
eqn6 = (D_point_r(1) - V_point_r(1) == Ltr_r * sind(a_t2) * cosd(a_t1) - La_r * sind(a_a)) ;
eqn7 = (D_point_r(2) - V_point_r(2) == Ltr_r * cosd(a_t2) * cosd(a_t1) - La_r * cosd(a_a) + Lr2_r * cosd(180 - (Alpha_r(i) + alpha_d_r))) ;
eqn8 = (D_point_r(3) - V_point_r(3) == - Lr2_r * sind(180 - (Alpha_r(i) + alpha_d_r)) + Ltr_r * cosd(a_t2) * sind(a_t1)) ;
eqns3 = [eqn6, eqn7, eqn8] ;
vars3 = [a_t1, a_t2, a_a] ;
% Solve
[A_t1, A_t2, A_a] = solve(eqns3, vars3) ;
alpha_t11 = double(vpa(A_t1)) ;
alpha_t21 = double(vpa(A_t2)) ;
alpha_a1 = double(vpa(A_a)) ;
ind = find(min(alpha_a1)); % want only the smallest angle possible
alpha_a = alpha_a1(ind);
alpha_t1 = alpha_t11(ind);
alpha_t2 = alpha_t21(ind);
Alpha_t1 = [Alpha_t1 alpha_t1] ;
Alpha_t2 = [Alpha_t2 alpha_t2] ;
Alpha_a = [Alpha_a alpha_a] ;
x_a = La_r * cosd(alpha_a) ;
X_a_r = [X_a_r x_a] ;
end
All the constants are previously defined in other scripts (the system is in a function file) :
D_point_r = [-1525, 256.9, 389.4];
V_point_r = [-1525, 0 , 459.4];
Ltr_r = 226.9;
La_r = 100;
Lr2_r = 100;
Alpha_r = linspace(28.5, 61.25, 40);
alpha_d_r = 80;
And I am getting the following output no matter what I try to do:
Warning: Solutions are parameterized by the symbols: x, z, z1. To include parameters and conditions in the solution, specify the 'ReturnConditions' value
as 'true'.
Warning: Solutions are valid under the following conditions: 7036874417766400*cos((z1*pi)/180) + 15849396699805925 ==
15967623867960408*cos((x*pi)/180)*cos((z*pi)/180) & cos((x*pi)/180)*sin((z*pi)/180) == 874303488919435/7983811933980204 & 0 < x &
879609302220800*sin((z1*pi)/180) == 1995952983495051*cos((z*pi)/180)*sin((x*pi)/180). To include parameters and conditions in the solution, specify the
'ReturnConditions' value as 'true'.
Error using symengine
Unable to convert expression into double array.
Error in sym/double (line 672)
Xstr = mupadmex('symobj::double', S.s, 0);
Error in ARB_motion_ratio (line 108)
alpha_t11 = double(vpa(A_t1)) ;
Error in main (line 172)
[mr_arb_f, mr_arb_r] = ARB_motion_ratio(l_UCA_new_f, Lp_f, l2_f, Lf_f, Lr2_f, Lr3_f, Ltr_f, La_f, Lb_f, delta_f, camber_angle_f, theta_2_f, O_point_f, G_point_f, W_point_f, Lr2_r, Ltr_r, La_r, alpha_d_r, D_point_r, V_point_r) ;
>>
I tried modifying the constants to see if matlab preferred but it doesn't change the outcome and solve is impossible to compute any values... :/
Thanks in advance for your help/advice

Respuestas (1)

Aghamarsh Varanasi
Aghamarsh Varanasi el 17 de Mzo. de 2020
Editada: Aghamarsh Varanasi el 17 de Mzo. de 2020
Hi,
I understand that you are trying to solve a system of equations using the solve function. And you are trying to get numeric solutions. The solve function may return parameterized solutions when solving a system of equations, when more than one solution is possible. As your system of equations involve trigonometric equations, more than one solution is possible.
There could be more than one workarounds for this problem.
  • If you needed to get the first solution for the system of equations, you could use the name value pair ‘PrincipalValue’ to true in the solve function. For example,
[A_t1, A_t2, A_a] = solve(eqns3, vars3, 'PrincipalValue', true)
  • You can also use vpasolve function instead of solve function to get numeric solutions. For example,
[A_t1, A_t2, A_a] = vpasolve(eqns3, vars3)
  • While using vpasolve, assumptions are not taken into consideration. Hence you could specify the range for a variable instead.
[A_t1, A_t2, A_a] = vpasolve(eqns3, vars3, x, [0 Inf])
You may refer to the following for more information.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by