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 CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by