Power method Matlab

1.1k Views Asked by At

I am trying to find the largest eigenvalue and its corresponding eigenvector by the

Power method

.. I did this code and I just want to display the largest eigenvalue and its eigenvector after asking the user to enter an n * n matrix.. can someone help me to add the right statements? Here is my code..

function [ v d] = power_method( A )

disp ( ' Enter the matrix whose eigen value is to be found')

% Calling matrix A

A = input ( ' Enter matrix A : \n')
% check for matrix A

% it should be a square matrix

[na , ma ] = size (A);
if na ~= ma
disp('ERROR:Matrix A should be a square matrix')
return
end

%display of final result

fprintf (' The largest eigen value obtained is \n')
disp('and the corresponding eigen vector is ')