フィルターのクリア

Error using gmres. Too many output arguments.

4 ビュー (過去 30 日間)
Hmm!
Hmm! 2021 年 11 月 25 日
回答済み: Hmm! 2021 年 11 月 26 日
I am pretty sure about this code that it is working I copied it from a textbook. But when I run it I get the error
"Error using gmres. Too many output arguments." I did all I could but I couldn't able to fix the problem, I think the reason being that I am not strong in matlab coding. Help needed.
clear
m=200;A=2*eye(m)+0.5*randn(m)/sqrt(m);b=ones(m,1);
[x,flag,relres,iter,resvec]=gmres(A,b);
figure(1)
plot(eig(A),'o');
hold on;
x=(1.5:0.001:2.5);
plot(x,sqrt(0.25-(x-2).^2),'r',x,-sqrt(0.25-(x-2).^2),'r');
legend('eigenvalues of A','(x-2)^2+y^2=1/4')
figure(2)
n=1:length(resvec);
semilogy(n,resvec);
hold on;
semilogy(n,4.^(-n),'r');
legend('||r^n||/||b||','4^{-n}');
hold off

採用された回答

Hmm!
Hmm! 2021 年 11 月 26 日
Yes. The resolution is that I had another file in the path folder with gmres so removing that file to a different folder did the magic. Thanks ot @Christine Tobler for the insight.

その他の回答 (1 件)

Yongjian Feng
Yongjian Feng 2021 年 11 月 25 日
It is working, at least for 2021a. Which version are you using please?
When matlab outputs an error, it normally tells you which line as well. Does it say line 3?
  2 件のコメント
Hmm!
Hmm! 2021 年 11 月 25 日
I am using MATLAB Version: 9.7.0.1261785 (R2019b) Update 3. It didn't tell me the line but when I run the code line by line, the error begins at
[x,flag,relres,iter,resvec]=gmres(A,b);
Christine Tobler
Christine Tobler 2021 年 11 月 25 日
Perhaps you have another file called gmres.m on the path, which overrides the standard one?
Try
which -all gmres
this should list any additional gmres.m that MATLAB might try to call here.

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by