Solve a system of equations
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 27 de Feb. de 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 comentarios
Lorenzo Stabile
el 28 de Feb. de 2019
Editada: Walter Roberson
el 28 de Feb. de 2019
Walter Roberson
el 28 de Feb. de 2019
Code attached. Solution is a small number of seconds once the Symbolic Toolbox has been initialized.
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!