help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extracting the dominant eigenvector


From: Mike Miller
Subject: Re: Extracting the dominant eigenvector
Date: Wed, 27 Mar 2002 22:24:53 -0600 (CST)

On Thu, 28 Mar 2002, Stefan Jonsson wrote:

> Hello octave users
>
> I have what I hope is a simple problem
>
> I have a square matrix, A, currently 10by10, may at
> later time have different dimensions.
>
> asking for eigenvalues and eigen vectors
>
> [vect, val] =eig(A); 
>
> I need the dominant eigenvalue and corresponding eigenvector


I suppose this will work for square matrix A of any size:

k=size(A,1);
[V,D]=eig(A);
[S,I]=sort(diag(D));
val=S(k);
vec=V(:,I(k));

You could write it as a function like this: [val, vec] = maxeig(A)

I use the 'sort' function which returns index I.  Read "help sort".

Regards,

Mike

-- 
Michael B. Miller, Ph.D.
Assistant Professor
Division of Epidemiology
University of Minnesota
http://taxa.epi.umn.edu/~mbmiller/



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]