How to extract a coefficient from a specific symbolic variable?

25 visualizaciones (últimos 30 días)
Nathan Batta
Nathan Batta el 24 de En. de 2020
Respondida: Walter Roberson el 24 de En. de 2020
Hello all!
I am modeling a suspension system and I have 6 very long equations of motion that I need to convert to state space. To create the matrices for the state space, I need the coefficient of each of my state variables. Is there a good way to extract these variables?
I looked at coeffs but since I have an equation and not a polynomial I couldn't get it to work.
By using collect I am able to easily view the coefficient for one variable at a time but it is very tedious and doesn't output the coefficient - it just makes it easy for me to see.
I don't have a lot of experience with Matlab so hopefully this is an easy fix. Thank you!

Respuestas (1)

Walter Roberson
Walter Roberson el 24 de En. de 2020
Sometimes you can isolate() the variable in the equation, after which coeffs() the lhs() of the equation.
Otherwise, lhs(eqn)-rhs(eqn) and coeffs() that to get the coefficient for the variable.

Categorías

Más información sobre Symbolic Math Toolbox 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!

Translated by