coefficients of differential equation defined by strings
Show older comments
I have a differential equation as string like
a*x1''[t] + b*cos(x2[t])*x1''[t] - n*x2'[t]*x1'[t]*sin(x2[t])-
c*(x2'[t])^2*sin(x2[t]) + g*cos(x1[t]) = In
and I want to extract the coefficients of
x1''[t], x1'[t], x2'[t]
and also extract the rest (which does not include any of these variables) as another term.
Is there a way to do it?
4 Comments
Walter Roberson
on 30 Apr 2018
regexp() for analysis.
However, you have terms inside of function calls such as cos(), so it is not clear that you want to come up with a single list of coefficients: it might make more sense to have a list for each function call level.
If different mentions of a variable have different coefficients, do you want the coefficients added together, or two separate entries? If added together, then what if they are at two different call levels?
Walter Roberson
on 30 Apr 2018
How do you want to handle the fact that you have x2'[t]^2 ? Do you want the coefficients for each power of each derivative ?
Analysis that needs to be able to handle (expression)^power and properly extract the coefficients of the variables by expansion, is not so easy to handle properly. Can we assume that the symbolic toolbox is present?
Answers (0)
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!