How to solve a simple Matrix equation?
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a small problem. I want to solve the multiplication of a given matrix.
For Example:
A = [-1,0,0,1;1,-1,0,0;0,1,-1,0;0,0,1,-1];
x = sym('x', [4,1]);
x(1,1)=1;
solve(A*x==[0;0;0;0])
Because I am a beginner at Matlab, I really don't know what im doing wrong. In this Example x should be equal to ones.
The goal is, to use it for a big matrix and calculate all unknown 'x'. If it is not possible to calculate them, I have to estimate the missing x, and solve it with something like a Netwon-Raphson method. But that will propably be in a later question.
Thank you for answering.
0 个评论
采纳的回答
Jon
2020-2-19
编辑:Jon
2020-2-19
It looks like you want to find all of the vectors satisfying Ax = 0 for some singular matrix , A. If so, you can do this using
X = null(A)
This returns a basis for the null space of a matrix A.
In your case MATLAB returns X = [0.5;0.5;0.5;0.5], any multiple of this will satisfy your equation,
so for example 2*[0.5;0.5;0.5,0.5] = [1;1;1;1] is a solution and you can verify that A*[1;1;1;1]=0
To find out more about the null function type doc null on the command line in MATLAB
7 个评论
Jon
2020-2-20
编辑:Jon
2020-2-20
Good catch!
Glad it seem like this approach will help you. One benefit of the least squares minimization, is that it very naturally handles the situation where you have sensor measurements of the flows but they may be noisy/slightly in error. Imagine that you in fact have all of the flows measured with noisy measurements. The measured flows will not satisfy Ax = 0 but you can find a set of flows which are as close as possible to the measured values (in the least square sense) but that satisfy Ax = 0. This is in some sense best physically consistent estimate of the overall network flows.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!