How can I solve a system of equations symbolically?

1 view (last 30 days)
This is the code that I'm trying to run:
clear;
clc;
syms F1 F2 F3 a m x1 x2 x3 L1 L2 L3;
F = [F1; F2; F3];
x = [x1; x2; x3];
b = [L1; L2; L3];
A = [1 2*m 0; a 3*m 1; 1 1 a];
%Solve F=A*x + b for x (x1, x2, x3)
solve('F1 = x1 + 2*m*x2 + L1', 'F2 = a*x1 +3*m*x2 + x3 + L2', 'F3 = x1 + x2 + a*x3', x1, x2, x3)
I'm trying to get it to solve for x1, x2, and x3 as a function fo the other values. Is there even a way to do this or am I trying to do something that MATLAB doesn't have the ability to do? Please help. Thanks!
Oh, the version of MATLAB I'm using is r2011a.
  1 Comment
Dan
Dan on 28 Sep 2012
Ideally, I'd like to just be able to say:
solve('F = A*x + b', x1, x2, x3);
I tried that and it didn't work. Is there anything similar to this that I could use?

Sign in to comment.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 28 Sep 2012
syms a m L1 L2 L3;
A = [1 2*m 0; a 3*m 1; 1 1 a];
b = [L1; L2; L3];
x = A\b
  1 Comment
Dan
Dan on 28 Sep 2012
This is exactly what I needed! Thank you. I guess I just didn't realize that this would still work. I thought I'd need to use solve for some reason. I did make the following adjustment:
syms F1 F2 F3;
F = [F1; F2; F3;];
B = F - b;
x = A\B
Thanks again!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!