Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: arrengment of eigenvalu and eigenvector

Subject: arrengment of eigenvalu and eigenvector

From: mustafa alheety

Date: 01 Jan, 2008 06:56:59

Message: 1 of 4

Dear all...
Hello...

happy new year frist. please i want to ask if that
possible in matlab to give my the eigenvalue and eigen
vector arrengement decreasing

Subject: Re: arrengment of eigenvalu and eigenvector

From: feras batah

Date: 01 Jan, 2008 07:08:50

Message: 2 of 4

"mustafa alheety" <alheety@yahoo.com> wrote in message
<flco7r$ieu$1@fred.mathworks.com>...
> Dear all...
> Hello...
>
> happy new year frist. please i want to ask if that
> possible in matlab to give my the eigenvalue and eigen
> vector arrengement decreasing


Hello Mustafa
also i need this solve and more information for this
problem in mat. porgram
thanks happy new year

Subject: Re: arrengment of eigenvalu and eigenvector

From: Roger Stafford

Date: 01 Jan, 2008 10:26:48

Message: 3 of 4

"feras batah" <ferashaker2001@yahoo.com> wrote in message <flcou2$rsg
$1@fred.mathworks.com>...
> "mustafa alheety" <alheety@yahoo.com> wrote in message
> <flco7r$ieu$1@fred.mathworks.com>...
> >
> > happy new year frist. please i want to ask if that
> > possible in matlab to give my the eigenvalue and eigen
> > vector arrengement decreasing
>
> Hello Mustafa
> also i need this solve and more information for this
> problem in mat. porgram
> thanks happy new year
------
  The trouble is that eigenvalues can very easily be complex-valued, and then
how would they be arranged in decreasing order? That is probably why
MathWorks' eig function does not atttempt to sort them.

  If you happen to know your eigenvalues are all real-valued, just use the sort
function to put them in decreasing order. Of course you would undoubtedly
want to rearrange the eigenvectors in the same way so as to preserve the
appropriate pairings of eigenvectors with matching eigenvalues.

Roger Stafford

Subject: Re: arrengment of eigenvalu and eigenvector

From: Bruno Luong

Date: 01 Jan, 2008 10:52:04

Message: 4 of 4

"mustafa alheety" <alheety@yahoo.com> wrote in message
<flco7r$ieu$1@fred.mathworks.com>...
> Dear all...
> Hello...
>
> happy new year frist. please i want to ask if that
> possible in matlab to give my the eigenvalue and eigen
> vector arrengement decreasing

I have sone a small m-file for you.

Bruno

function [varargout]=seig(varargin)
% function [varargout]=seig(varargin);
% SEIG sorted Eigenvalues and eigenvectors.
% Calling: similar MATLAB builtin EIG with optional
% last parameter can be 'ascend' or 'descend'
% for sorting purpose
%
% Related function eig and sort
%

vin=varargin;
sopt='';
% Look where as last argument is 'ascend' or 'descend'
if length(varargin)>=2 && ischar(varargin{end})
    sopt=lower(varargin{end});
    switch sopt
        case {'ascend' 'descend'}
            vin=varargin(1:end-1);
    end
end

nout=max(nargout,1);
varargout=cell(1,nout);
[varargout{:}]=eig(vin{:}); % call eig

if ~isempty(sopt)
    if nout==1 % Calling with 1 output
        varargout{1}=sort(varargout{1},sopt);
    else % Calling with 2 outputs
        [ds is]=sort(diag(varargout{2}),sopt);
        varargout{2}=diag(ds);
        varargout{1}=varargout{1}(:,is); % rearrange
eigen-vectors
    end
end

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics