How to solve a simple Matrix equation?

2 ビュー (過去 30 日間)
Phillipp
Phillipp 2020 年 2 月 19 日
編集済み: Jon 2020 年 2 月 20 日
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.

採用された回答

Jon
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 件のコメント
Phillipp
Phillipp 2020 年 2 月 20 日
I have the optimization toolbox installed.Thank you! That really helped me.
You made a tiny mistake you have to change this:
lb = zeros(numNodes,1); % lower bound, flows must be greater than zero
to this.
lb = zeros(numPipes,1); % lower bound, flows must be greater than zero
But man, you really helped me out. Thanks a lot.
Jon
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 ExchangeLinear Least Squares についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by