フィルターのクリア

the loop is not converging it is giving me an infinite value(it is increasing)

1 回表示 (過去 30 日間)
Mahmoud Chawki
Mahmoud Chawki 2023 年 5 月 20 日
移動済み: Matt J 2023 年 5 月 20 日
clear variables
close all
clc
A = [1 1 2; 1 2 4; 1 2 5];
x = [1; 2; 3];
Error = 0.00001;
Diff= 1;
while Diff>Error
x1=A*x;
Diff=norm(x1-x);
x=x1;
end
  1 件のコメント
Mahmoud Chawki
Mahmoud Chawki 2023 年 5 月 20 日
still not working still not working the answer is infinity for x and NAN for Diff

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

回答 (1 件)

Torsten
Torsten 2023 年 5 月 20 日
移動済み: Matt J 2023 年 5 月 20 日
Why do you think your fixed-point iteration should converge ?
If the absolute values of the eigenvalues of A were all < 1, it would work. But it is not the case:
A = [1 1 2; 1 2 4; 1 2 5];
eig(A)
ans = 3×1
7.1842 0.5728 0.2430
  5 件のコメント
Torsten
Torsten 2023 年 5 月 20 日
移動済み: Matt J 2023 年 5 月 20 日
What do you mean by "make it work" ? It works as you have programmed it and gives you the correct result for the matrix A and the initial vector x: Divergence.
Mahmoud Chawki
Mahmoud Chawki 2023 年 5 月 20 日
移動済み: Matt J 2023 年 5 月 20 日
i found the answer, i need to normalize the new vector before using it again. thank you

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

カテゴリ

Help Center および File ExchangeSparse Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by