Issue using sum() for QR method script
1 回表示 (過去 30 日間)
古いコメントを表示
The following is a cut-out from a QR method script for finding all the eigenvalues of a matrix. When the line for a(:,i)=.... is run within the 'for' loop it fails to complete. I am trying to mimic the expression from the image below with a(:,i) and having a lot of trouble, please help me.
A=[8 -2 -2; -2 4 -2; -2 -2 13]; %initial matrix
k=0; %starts iteration count
while ((max(abs((lambdak-lambda0)/lambda0))>toler) && (k<maxiter)); %as long as the change between the previous and current lamda are >toler, keep going until you hit the iteration limit
lambda0=lambdak; %establish baseline values for lamda
k=k+1; %iteration number for display +1
a=A;
q(:,1)=a(:,1)./norm(a(:,1));
for i=2:n
a_p(:,i)=a(:,i)-sum(transpose(q(:,i-1))*a(:,i).*q(:,i-1),i,1,i-1) %where I am getting stuck
q(:,i)=a_p(:,i)./norm(a_p(:,i))
end
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156881/image.jpeg)
0 件のコメント
回答 (1 件)
Brandon Eidson
2016 年 10 月 7 日
編集済み: Brandon Eidson
2016 年 12 月 29 日
Hey Chris,
It looks to me that your implementation of the "sum" function is incorrect. This function only takes two inputs, but I think you are passing it four inputs. See the documentation at the link below.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!