フィルターのクリア

Impossible Ax=b is solved by linesolve(A,b) and mldivide(A,B)

2 ビュー (過去 30 日間)
Pedro
Pedro 2012 年 8 月 14 日
A=[-1 2 3;0 1 -1;2 0 5;1 3 2]
B=[1 1 1 1]'
x=linsolve(A,B)
x =
0.1111
0.3333
0.1111
x=mldivide(A,B)
x =
0.1111
0.3333
0.1111
HOwever A*x
ans =
0.8889
0.2222
0.7778
1.3333
and b= [1 1 1 1]'
If I solve the system in paper, the system is impossible but matlab says it´s possible. When I test matlab answer, it is wrong. If I do A=sym([-1 2 3;0 1 -1;2 0 5;1 3 2])
colspace(A) A =
[ -1, 2, 3] [ 0, 1, -1] [ 2, 0, 5] [ 1, 3, 2]
ans =
[ 1, 0, 0] [ 0, 1, 0] [ 0, 0, 1] [ 1/3, 7/3, 2/3]
The system seems possible but I think it isn't. Can someone tell me what's going on? How do I know if the system is possible?

採用された回答

Matt Fig
Matt Fig 2012 年 8 月 14 日
編集済み: Matt Fig 2012 年 8 月 14 日
From the documentation:
" If A is an m-by-n matrix with m ~= n and B is a column vector with m components, or a matrix with several such columns, then X = A\B is the solution in the least squares sense to the under- or overdetermined system of equations AX = B. In other words, X minimizes norm(A*X - B), the length of the vector AX - B. The rank k of A is determined from the QR decomposition with column pivoting. The computed solution X has at most k nonzero elements per column. If k < n, this is usually not the same solution as x = pinv(A)*B, which returns a least squares solution. "
You have 4 equations and 3 unknowns. This is an overdetermined system, so MATLAB is following the documentation.
  5 件のコメント
Matt Fig
Matt Fig 2012 年 8 月 14 日
Sure, just make a little function.
isexact = @(A,x,B) max((A*x-B))<1e-13; % Choose your tol.
Now,
A=[-1 2 3;0 1 -1;2 0 5;1 3 2];
B=[1 1 1 1]';
x = A\B;
isexact(A,x,B) % Returns 0 == not exact.
But, let's try with:
A=[-1 2 3;0 1 -1;2 0 5];
B=[2 3 4]';
x = A\B;
isexact(A,x,B) % Returns 1 == yes exact
Pedro
Pedro 2012 年 8 月 14 日
wow.. didn't know matlab was that easy to program. Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by