How to solve a system of equations symbolically? (MATLAB R2011a)
Show older comments
This is what I'm trying to do:
syms x1 x2 x3 X1 X2 X3 t
S = solve('x1 = 3*t*X1+X2', 'x2 = 2*t^2*X2', 'x3 = 5*t*X3')
S = [S.X1 S.X2 S.X3]
I get a reference to non-existent field error though.
It's solving for x1, x2, and x3, but need to solve for X1, X2, and X3 in terms of x1, x2, x3 and t.
Please help! Thanks!
Answers (1)
Azzi Abdelmalek
on 30 Nov 2012
Edited: Azzi Abdelmalek
on 30 Nov 2012
syms x1 x2 x3 X1 X2 X3 t
S = solve(x1==3*t*X1+X2, x2==2*t^2*X2, x3==5*t*X3,X1,X2,X3)
S = [S.X1 S.X2 S.X3]
6 Comments
Dan
on 30 Nov 2012
Azzi Abdelmalek
on 30 Nov 2012
VERSION OF MATLAB?
Azzi Abdelmalek
on 30 Nov 2012
try this
clear
syms x1 x2 x3 X1 X2 X3 t
S = solve(x1==3*t*X1+X2, x2==2*t^2*X2, x3==5*t*X3,X1,X2,X3)
S = [S.X1 S.X2 S.X3]
Walter Roberson
on 30 Nov 2012
R2011a did not support using == in symbolic expressions. I think it was R2011b that first supported that.
S = solve('x1=3*t*X1+X2', 'x2=2*t^2*X2', 'x3=5*t*X3','X1','X2','X3')
Azzi Abdelmalek
on 30 Nov 2012
Then no need to use syms
Walter Roberson
on 1 Dec 2012
Yes, correct. If everything is quoted, syms is not needed.
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!