Solving a System of Equations with syms

2 Ansichten (letzte 30 Tage)
Kevin Bachovchin
Kevin Bachovchin am 14 Feb. 2013
Hello,
I have a system of 10 equations and 14 unknowns. I want to solve this system of equations for 6 particular unknowns in terms of the other unknowns.
When I use solve(Equations==0) then it successfully solves for 10 unknowns in terms of the other 4 unknowns. However, I can't control which 10 unknowns MATLAB solves for.
When I try to specify 6 of the unknowns MATLAB solves for and use solve(Equations==0,x1,x2,x3,x4,x5,x6) then I get an empty matrix as my answer.
Can someone please tell me how I can correctly specify the 6 unknowns that I want MATLAB to solve for?
Thank you, Kevin
  3 Kommentare
Walter Roberson
Walter Roberson am 14 Feb. 2013
Perhaps the equations are not solvable with respect to those 6 variables.
Kevin Bachovchin
Kevin Bachovchin am 14 Feb. 2013
Bearbeitet: Walter Roberson am 14 Feb. 2013
Seems like I have to specify all 10 substitution variables for solving the other 4 variables, but I think that is ok for my purpose.
When I used, solve(Equations==0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10), then that successfully solves for x11,x12,x13,x14.
Do you know is there a way to specify the substitution variables as a matrix? Doing
XSubsitute = [x1,x2,x3,x4,x5,x6,x7,x8,x9,x10]
solve(Equations==0,XSubstitute)
produces an empty matrix as my answer.
I really need to be able to specify the substitution variables as the elements in the matrix to be able to apply my code for a general problem.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 14 Feb. 2013
Bearbeitet: Walter Roberson am 14 Feb. 2013
XSubstitute = {x1,x2,x3,x4,x5,x6,x7,x8,x9,x10}
solve(Equations==0,XSubstitute{:})
  6 Kommentare
Walter Roberson
Walter Roberson am 14 Feb. 2013
You could work with struct2cell()
Kevin Bachovchin
Kevin Bachovchin am 14 Feb. 2013
The problem with this is that I lose the field names then. There's no way to directly extract the first N fields and values from a struct and then put in another struct? Something like answer2 = answer{1:N}?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by