フィルターのクリア

Least square magnitude solution

2 ビュー (過去 30 日間)
Cesar Cardenas
Cesar Cardenas 2022 年 8 月 28 日
コメント済み: Cesar Cardenas 2022 年 8 月 28 日
is this a right approach to calculate the least square magnitude x* to this problem? Any help will be greatly appreciated. Thanks
A = [1 2 3 4 5; 6 7 8 9 0];
b = [1;2];
x = lsqr(A,b)
e2 = b - A*x
norm(e2)

採用された回答

Torsten
Torsten 2022 年 8 月 28 日
編集済み: Torsten 2022 年 8 月 28 日
A = [1 2 3 4 5; 6 7 8 9 0];
b = [1;2];
x = lsqminnorm(A,b).'
x = 1×5
0.0400 0.0560 0.0720 0.0880 0.0560
norm(x)
ans = 0.1442
norm(A*x.'-b)
ans = 0
if you search for the solution for which x has minimum norm.
If you only search for an arbitrary least-squares solution (i.e. for an x for which norm(e2) is minimum), simply use
x = (A\b).'
x = 1×5
0 0 0 0.2222 0.0222
norm(x)
ans = 0.2233
norm(A*x.'-b)
ans = 2.2204e-16
  1 件のコメント
Cesar Cardenas
Cesar Cardenas 2022 年 8 月 28 日
Right thank so much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStrategy & Logic についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by