Error using sym/coeffs. First argument must be a scalar.

syms q1(t) q2(t) q3(t) q4(t) q5(t) q6(t) q1_hiz(t) q2_hiz(t) q3_hiz(t) q4_hiz(t) q5_hiz(t) q6_hiz(t) q1_ivme(t) q2_ivme(t) q3_ivme(t) q4_ivme(t) q5_ivme(t) q6_ivme(t) t
After various transactions, i get for example that equation:
VG1_O =
-0.4250*cos(q1(t))*q1_hiz(t)
-0.4250*sin(q1(t))*q1_hiz(t)
0
When i take the coefficients of that matrix as q2_hiz(t); it is expected that solution will be 0 however the solution is like this:
ff=coeffs(VG1_O(1,1),[q2_hiz(t)]);
ff=
-0.4250*cos(q1(t))*q1_hiz(t)
How can i solve this problem?

 Respuesta aceptada

Torsten
Torsten el 12 de En. de 2023
Editada: Torsten el 12 de En. de 2023
My guess is that VG1_0(1,1) is interpreted as a polynomial in the variable q2_hiz(t).
Since your expression does not contain q2_hiz(t), -0.4250*cos(q1(t))*q1_hiz(t) is the constant term of the polynomial
-0.4250*cos(q1(t))*q1_hiz(t) + 0*q2_hiz(t) + 0*q2_hiz(t)^2 + ...
and is thus returned by "coeffs".

5 comentarios

Mustafa Duran
Mustafa Duran el 12 de En. de 2023
Editada: Mustafa Duran el 12 de En. de 2023
Thanks, I understand now. Is there any tool that do what i want correctly?
Since I don't understand what you want, I cannot give advice.
Maybe you want to use "diff" ?
syms t q1(t) q1_hiz(t) q2_hiz(t)
expr = -0.4250*cos(q1(t))*q1_hiz(t);
ff = diff(expr,q2_hiz(t))
ff = 
0
I just want to when i ask MATLAB for what is the coefficient of q2_hiz(t) or q3_hiz(t) in expr; it must give me 0.
That's what the diff command does - if a variable does not appear in an expression, the derivative with respect to this variable is 0. And if you want the coefficient of q1_hiz(t), the command will give you -0.4250*cos(q1(t)).
syms t q1(t) q1_hiz(t) q2_hiz(t) q3_hiz(t)
expr = -0.4250*cos(q1(t))*q1_hiz(t);
ff1 = diff(expr,q1_hiz(t))
ff1 = 
ff2 = diff(expr,q2_hiz(t))
ff2 = 
0
ff3 = diff(expr,q3_hiz(t))
ff3 = 
0
Mustafa Duran
Mustafa Duran el 12 de En. de 2023
Editada: Mustafa Duran el 12 de En. de 2023
You're right. Solution is so basic however i didn't think it is that much simple even if i know derivative. Sometimes it is better to take opinions of others. Thanks so much for responding my questions.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 12 de En. de 2023

Editada:

el 12 de En. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by