function lmax = maxeig(A) % This function performs an eigenanalysis of % matrix A and returns the maximum eigenvalue % (the maximum real part if complex). % It is for programming demonstration purposes % only. In particular, the same effect is % easily obtained using matlab 'max' and % 'eig' commands: % >> max(eig(A)) % If you see built-in commands you don't know, % just type 'help command' at the matlab prompt, % or do a search for that command name % in the web help desk. lambda = real(eig(A)); n = length(lambda); lmax = -inf; for i = 1:n if lambda(i) > lmax lmax = lambda(i); end end