hello, how to solve the problem for matrix that a is diagonal matrix and u is random column matrix. I would like to solve the equation to get u=a*u inside the loop. But , I got index in the position 2 is invalid answer. Could you please help me?

2 ビュー (過去 30 日間)
e=ones(10,1);
a=spdiags([-e 2*e -e],-1:1,10,10);
A=full(a);
u=rand(10,1);
for k=0:9
u(:,k+1)=(A*u(:,k))/norm(A*u(:,k));
end

採用された回答

Alan Stevens
Alan Stevens 2020 年 8 月 26 日
Matlab's indexing starts at 1 not zero, so it is complaining at u(:,k) when k is zero.
  1 件のコメント
Thin Rupar Win
Thin Rupar Win 2020 年 8 月 26 日
Thank you very much Alan Stevens. Have a nice day.

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by