📄 power.mht
字号:
From: <Saved by Windows Internet Explorer 7>
Subject:
Date: Tue, 12 May 2009 09:56:27 -0700
MIME-Version: 1.0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit
Content-Location: http://www.mece.ualberta.ca/Courses/mec390/390code/power.m
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.6000.16825" name=GENERATOR></HEAD>
<BODY><PRE>%
% Solution of Eigen-value problem using the Power Method
%
A = [2 -1 0 0;-1 2 -1 0;0 -1 2 -1; 0 0 -1 2] % coef matrix
y = [1; 0; 0; 0] % starting vector
fprintf('\nPower Method Demonstration\n\n');
highlow = input('Determine highest (1) or lowest (2) eigenvalue: ');
if highlow == 2 % lowest eigenvalue case: calc matrix inverse
A = inv(A);
end;
lambda_old = 1;
error = 1;
count = 0;
while abs(error) > 0.01
count = count + 1;
y = A * y; % new eigenvalue
lambda = max(y); % new lambda
y = y/lambda; % normalize
error = (lambda - lambda_old)/lambda * 100;
lambda_old = lambda;
fprintf('# %i Lambda = %f Error = %f\n',count,lambda, error);
end;
if highlow == 1
fprintf('\nHighest eigenvalue is %f\n',lambda);
else
fprintf('\nLowest eigenvalue is %f\n',1/lambda);
end;
</PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -