フィルターのクリア

Create for loop in a matrix (power method)

2 ビュー (過去 30 日間)
Roy dela Rama
Roy dela Rama 2016 年 3 月 9 日
回答済み: Roy dela Rama 2016 年 3 月 9 日
Estimate the most dominant eigenvalue of [A] and its corresponding eigenvector,using the power method.
A = [4 3 1;
3 -6 0;
1 0 2];
B = [1;
1;
1];
n = 50; % number of iterations
C = A*B % iterative equation
[maxC, index] = max (abs(C(:)));
maxC = maxC * sign(C(index))
% largest magnitude in matrix C (courtesy of IMAGE ANALYST)
D = C/maxC % factor out the largest magnitude in matrix C
B = D % this is the new value of B
I want to use the new value of B in C = A*B until it reaches 50 iterations. Expected answers are
maxC = -6.83909
D = -0.279693
1
0.0316436
I get an error message whenever I try the for loop..

回答 (1 件)

Roy dela Rama
Roy dela Rama 2016 年 3 月 9 日
I already figured it out. I don't need to use C(i+1) for my iteration equation for this particular matrix.
All I have to do is proceed with for loop:
for i = 1:n;
C = A*B
[maxC, index] = max (abs(C(:)));
maxC = maxC * sign(C(index))
D = C/maxC % factor out the largest magnitude in matrix C
B = D % this is the new value of B
end
This will result with my expected answers

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by