Clear Filters
Clear Filters

How to get coefficients of equation defined by symbolic variable equation.?

6 views (last 30 days)
I have number of symbolic variable defined by as follow:
% a1, a2, a3, a4, a5
a = sym('a',[1 5]);
Now I have an equation.. eqn = 3*a1 - 6*a3 + 9*a5 == 45;
I want to separate all the coefficients of above equation and store in 1*5 matrix.
I also want to store constant (=45) into another vector.

Accepted Answer

Walter Roberson
Walter Roberson on 9 Jun 2017
[A,B] = equationsToMatrix(eqn,a)
A will be the coefficients and B will be what it equals

More 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!