Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Simple ODE: Linearly Damped Spring Mass System
Date: Tue, 27 Jan 2009 17:00:33 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 40
Message-ID: <glnejh$m7u$1@fred.mathworks.com>
References: <gkjq5e$ph5$1@fred.mathworks.com> <gkjueb$1ts$1@fred.mathworks.com> <gkk08e$3dv$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1233075633 22782 172.30.248.35 (27 Jan 2009 17:00:33 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 27 Jan 2009 17:00:33 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1376919
Xref: news.mathworks.com comp.soft-sys.matlab:514300


Thanks so much Bruno, and sorry for the late reply.

so here is my attempt in solving the problem using the eig. value problem:


m = rand(6,6); c = rand(6,6); k = rand(6,6); % note these are not the actual values, the are to illustrate my problem here only

w=7; tlim=[0,100]; nt=400;

n=size(m,1); t=linspace(tlim(1),tlim(2),nt);
% Initial conditions 
y0=[1;1;1;1;1;1]; v0=zeros(6,1); y0=0*y0;  

% eigenvalues and eigenvectors for the homogeneous solution
A=[zeros(n,n), eye(n,n); -m\[k, c]];
[U,lam]=eig(A); [lam,j]=sort(diag(lam)); U=U(:,j);

% homogeneous solution 
U=U*diag(U\[y0; v0]);
yh=real(U(1:n,:)*exp(lam*t));

Problems:

when I use the real part of complex m, c & k, the eig. values are:
lam =

        0          
        0          
        0          
  -0.0023          
  -0.1068          
  -0.1068          
  -0.1418 - 0.7198i
  -0.1418 + 0.7198i
  -0.1418 - 0.7198i
  -0.1418 + 0.7198i
  -0.0973 - 0.8748i
  -0.0973 + 0.8748i

Problem: the above method does not like zero eig. values. so my second option is to use ode45 and solve the problem numerically, but I'm not sure how to find the homogeneous solution using this numerical function? any tips will be great.