Solve a system of equations
Afficher commentaires plus anciens
I have to solve a system of equations in the form Ax=b+F, where A is a known 8x8 matrix. Also the term F is all known.
The problem is that I have unknowns both in the term x and b (4 in x and 4 in b, the other terms are given by boundary conditions).
How can I set the problem on matlab?
Thanks.
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 27 Fév 2019
A = sym('A',[8 8],'real');
x = sym('x',[8 1]);
b = sym('b',[8 1]);
F = sym('F',[8 1]);
sol = solve(A*x == b+F,[x(1:4);b(5:8)]); %choose appropriate variables to solve for
sol will be a struct with one field for each variable solved for.
The above is the general solution, at least under the assumption that F does not depend upon the other variables.
It is not a fast solution. If you were to put in your known numeric values then it would probably go more quickly.
2 commentaires
Lorenzo Stabile
le 28 Fév 2019
Modifié(e) : Walter Roberson
le 28 Fév 2019
Walter Roberson
le 28 Fév 2019
Code attached. Solution is a small number of seconds once the Symbolic Toolbox has been initialized.
Catégories
En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!