<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242334</link>
    <title>MATLAB Central Newsreader - Simple ODE: Linearly Damped Spring Mass System</title>
    <description>Feed for thread: Simple ODE: Linearly Damped Spring Mass System</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 14 Jan 2009 04:37:02 -0500</pubDate>
      <title>Simple ODE: Linearly Damped Spring Mass System</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242334#621398</link>
      <author>Hydroman S</author>
      <description>In Matlab, How can I solve a Linear Second Order Homogenous ODE in Matrix form, i.e. &lt;br&gt;
&lt;br&gt;
M x&amp;#8217;&amp;#8217; + C x&amp;#8217; + k x = 0&lt;br&gt;
Where M, C, K are 6x6 complex matrices, and x is a function of time. &lt;br&gt;
and some initial conditions, i.e.  x(0)=1. &lt;br&gt;
&lt;br&gt;
I cannot find references that address this problem in the matrix form. Any tips will be appricated. Thanks, </description>
    </item>
    <item>
      <pubDate>Wed, 14 Jan 2009 05:50:03 -0500</pubDate>
      <title>Re: Simple ODE: Linearly Damped Spring Mass System</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242334#621408</link>
      <author>Bruno Luong</author>
      <description>&quot;Hydroman S&quot; &amp;lt;amirgsalem@gmail.com&amp;gt; wrote in message &amp;lt;gkjq5e$ph5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; In Matlab, How can I solve a Linear Second Order Homogenous ODE in Matrix form, i.e. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; M x&amp;#8217;&amp;#8217; + C x&amp;#8217; + k x = 0&lt;br&gt;
&amp;gt; Where M, C, K are 6x6 complex matrices, and x is a function of time. &lt;br&gt;
&amp;gt; and some initial conditions, i.e.  x(0)=1. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I cannot find references that address this problem in the matrix form. Any tips will be appricated. Thanks,&lt;br&gt;
&lt;br&gt;
Why do you need any reference? take a look of doc ODE?? (especially Mass matrix part), your system can be solved by those functions without any further manipulation.&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Wed, 14 Jan 2009 06:21:02 -0500</pubDate>
      <title>Re: Simple ODE: Linearly Damped Spring Mass System</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242334#621412</link>
      <author>Bruno Luong</author>
      <description>&quot;Bruno Luong&quot; &amp;lt;b.luong@fogale.findmycountry&amp;gt; wrote in message &amp;lt;gkjueb$1ts$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Hydroman S&quot; &amp;lt;amirgsalem@gmail.com&amp;gt; wrote in message &amp;lt;gkjq5e$ph5$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; In Matlab, How can I solve a Linear Second Order Homogenous ODE in Matrix form, i.e. &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; M x&amp;#8217;&amp;#8217; + C x&amp;#8217; + k x = 0&lt;br&gt;
&amp;gt; &amp;gt; Where M, C, K are 6x6 complex matrices, and x is a function of time. &lt;br&gt;
&amp;gt; &amp;gt; and some initial conditions, i.e.  x(0)=1. &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I cannot find references that address this problem in the matrix form. Any tips will be appricated. Thanks,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Why do you need any reference? take a look of doc ODE?? (especially Mass matrix part), your system can be solved by those functions without any further manipulation.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Bruno&lt;br&gt;
&lt;br&gt;
One more remark, I guess your variable x is (6 x 1) vector.&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Tue, 27 Jan 2009 17:00:33 -0500</pubDate>
      <title>Re: Simple ODE: Linearly Damped Spring Mass System</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242334#624340</link>
      <author>Hydroman S</author>
      <description>Thanks so much Bruno, and sorry for the late reply.&lt;br&gt;
&lt;br&gt;
so here is my attempt in solving the problem using the eig. value problem:&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
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&lt;br&gt;
&lt;br&gt;
w=7; tlim=[0,100]; nt=400;&lt;br&gt;
&lt;br&gt;
n=size(m,1); t=linspace(tlim(1),tlim(2),nt);&lt;br&gt;
% Initial conditions &lt;br&gt;
y0=[1;1;1;1;1;1]; v0=zeros(6,1); y0=0*y0;  &lt;br&gt;
&lt;br&gt;
% eigenvalues and eigenvectors for the homogeneous solution&lt;br&gt;
A=[zeros(n,n), eye(n,n); -m\[k, c]];&lt;br&gt;
[U,lam]=eig(A); [lam,j]=sort(diag(lam)); U=U(:,j);&lt;br&gt;
&lt;br&gt;
% homogeneous solution &lt;br&gt;
U=U*diag(U\[y0; v0]);&lt;br&gt;
yh=real(U(1:n,:)*exp(lam*t));&lt;br&gt;
&lt;br&gt;
Problems:&lt;br&gt;
&lt;br&gt;
when I use the real part of complex m, c &amp; k, the eig. values are:&lt;br&gt;
lam =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0          &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0          &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0          &lt;br&gt;
&amp;nbsp;&amp;nbsp;-0.0023          &lt;br&gt;
&amp;nbsp;&amp;nbsp;-0.1068          &lt;br&gt;
&amp;nbsp;&amp;nbsp;-0.1068          &lt;br&gt;
&amp;nbsp;&amp;nbsp;-0.1418 - 0.7198i&lt;br&gt;
&amp;nbsp;&amp;nbsp;-0.1418 + 0.7198i&lt;br&gt;
&amp;nbsp;&amp;nbsp;-0.1418 - 0.7198i&lt;br&gt;
&amp;nbsp;&amp;nbsp;-0.1418 + 0.7198i&lt;br&gt;
&amp;nbsp;&amp;nbsp;-0.0973 - 0.8748i&lt;br&gt;
&amp;nbsp;&amp;nbsp;-0.0973 + 0.8748i&lt;br&gt;
&lt;br&gt;
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. </description>
    </item>
    <item>
      <pubDate>Tue, 27 Jan 2009 17:12:02 -0500</pubDate>
      <title>Re: Simple ODE: Linearly Damped Spring Mass System</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242334#624348</link>
      <author>Hydroman S</author>
      <description>&amp;gt; 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. &lt;br&gt;
===============================================================================================================================================================&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
One more thing: In one reference I found on the file exchange section of this site which deals with a similar problem, but with a forcing function F(t) such that the equation of motion will have a homogenous + a particular solution. &lt;br&gt;
&lt;br&gt;
M*X&quot;+C*X'+K*X=F(t) &lt;br&gt;
&lt;br&gt;
&amp;nbsp;A typical call to strdynrk function is:&lt;br&gt;
&amp;nbsp;m=eye(3,3); k=[2,-1,0;-1,2,-1;0,-1,2];&lt;br&gt;
&amp;nbsp;c=.05*k; x0=zeros(3,1); v0=zeros(3,1);&lt;br&gt;
&amp;nbsp;t=linspace(0,10,101);&lt;br&gt;
&amp;nbsp;[t,x,v]=strdynrk(t,x0,v0,m,c,k,'func');&lt;br&gt;
&lt;br&gt;
global Mi C K F n n1 n2&lt;br&gt;
Mi=inv(m); C=c; K=k; F=functim;&lt;br&gt;
n=size(m,1); n1=1:n; n2=n+1:2*n;&lt;br&gt;
[t,z]=ode45(@sde,t,[x0(:);v0(:)]);&lt;br&gt;
x=z(:,n1); v=z(:,n2);&lt;br&gt;
&amp;nbsp;&lt;br&gt;
%================================&lt;br&gt;
&lt;br&gt;
function zp=sde(t,z)&lt;br&gt;
% zp=sde(t,z)&lt;br&gt;
global Mi C K F n n1 n2&lt;br&gt;
zp=[z(n2); Mi*(feval(F,t)-C*z(n2)-K*z(n1))];&lt;br&gt;
&lt;br&gt;
%================================&lt;br&gt;
&lt;br&gt;
function f=func(t)&lt;br&gt;
% f=func(t)&lt;br&gt;
% This is an example forcing function for  &lt;br&gt;
% function strdynrk in the case of three&lt;br&gt;
% degrees of freedom. &lt;br&gt;
f=[-1;0;2]*sin(1.413*t);&lt;br&gt;
&lt;br&gt;
My question then becomes, how to get the homogenous solution zh instead of zp, simply making f = [0;0;0] will not do the job, right?</description>
    </item>
    <item>
      <pubDate>Wed, 28 Jan 2009 13:53:01 -0500</pubDate>
      <title>Re: Simple ODE: Linearly Damped Spring Mass System</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242334#624514</link>
      <author>Hydroman S</author>
      <description>Sorry to bring this up again, but I was hoping that maybe anyone who is familiar with solving ODE&amp;#8217;s numerically in Matlab could help me finalize the problem of finding the homogenous solution using ODE45 based on the equation below in the matrix form:&lt;br&gt;
&lt;br&gt;
M*X&quot;+C*X'+K*X=0 </description>
    </item>
    <item>
      <pubDate>Wed, 28 Jan 2009 14:29:21 -0500</pubDate>
      <title>Re: Simple ODE: Linearly Damped Spring Mass System</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242334#624524</link>
      <author>Torsten Hennig</author>
      <description>&amp;gt; Sorry to bring this up again, but I was hoping that&lt;br&gt;
&amp;gt; maybe anyone who is familiar with solving ODE&#8217;s&lt;br&gt;
&amp;gt; numerically in Matlab could help me finalize the&lt;br&gt;
&amp;gt; problem of finding the homogenous solution using&lt;br&gt;
&amp;gt; ODE45 based on the equation below in the matrix form:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; M*X&quot;+C*X'+K*X=0 &lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Your system can be written as a first-order system&lt;br&gt;
as&lt;br&gt;
X' = Y&lt;br&gt;
M*Y' = -K*X-C*Y&lt;br&gt;
or (if M is regular)&lt;br&gt;
X' = Y&lt;br&gt;
Y' = -M^(-1)*K*X-M^(-1)*C*Y&lt;br&gt;
Write this system as &lt;br&gt;
Z' = A*Z&lt;br&gt;
with Z=(X,Y) and A = [0,I ; -M^(-1)*K, -M^(-1)*C] &lt;br&gt;
Then (X,Y)=exp(A*t)*(X_0,Y_0) is the solution of&lt;br&gt;
the homogenous equation with exp being the matrix&lt;br&gt;
exponential.&lt;br&gt;
&lt;br&gt;
Take a look at&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/index.html?/access/helpdesk/help/toolbox/symbolic/expm.html&amp;http://www.google.de/search?hl=de&amp;q=MATLAB+%26+symbolic+matrix+exponential&amp;meta=&quot;&gt;http://www.mathworks.com/access/helpdesk/help/toolbox/symbolic/index.html?/access/helpdesk/help/toolbox/symbolic/expm.html&amp;http://www.google.de/search?hl=de&amp;q=MATLAB+%26+symbolic+matrix+exponential&amp;meta=&lt;/a&gt; &lt;br&gt;
for the calculation of the matrix exponential.&lt;br&gt;
&lt;br&gt;
Best wishes&lt;br&gt;
Torsten.</description>
    </item>
    <item>
      <pubDate>Wed, 28 Jan 2009 14:40:27 -0500</pubDate>
      <title>Re: Simple ODE: Linearly Damped Spring Mass System</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242334#624525</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Hydroman S&quot; &amp;lt;amirgsalem@gmail.com&amp;gt; wrote in message &lt;br&gt;
news:glpnvt$pa8$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; Sorry to bring this up again, but I was hoping that maybe anyone who is &lt;br&gt;
&amp;gt; familiar with solving ODE&amp;#8217;s numerically in Matlab could help me &lt;br&gt;
&amp;gt; finalize the problem of finding the homogenous solution using ODE45 based &lt;br&gt;
&amp;gt; on the equation below in the matrix form:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; M*X&quot;+C*X'+K*X=0&lt;br&gt;
&amp;gt;&lt;br&gt;
&lt;br&gt;
Convert the 2nd order ODE into a system of 1st order ODEs [massMatrix*y' = &lt;br&gt;
f(t, y)] and use ODE45 to solve this system.  If you're not sure how to &lt;br&gt;
generate the system of ODEs from the single 2nd order ODE, go to the support &lt;br&gt;
website:&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/support&quot;&gt;http://www.mathworks.com/support&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
and search for &quot;higher order ODE&quot;.  The first two hits each include examples &lt;br&gt;
of how to do that.&lt;br&gt;
&lt;br&gt;
Alternately, you could use ODE15I, which can handle ODEs of the form f(t, y, &lt;br&gt;
y') = 0.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Thu, 29 Jan 2009 16:35:03 -0500</pubDate>
      <title>Re: Simple ODE: Linearly Damped Spring Mass System</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242334#624796</link>
      <author>Hydroman S</author>
      <description>Thank you Torsten and Steve, Torsten your example works well, I just have to incorparate the inatial condtions, which I know how to do.&lt;br&gt;
&lt;br&gt;
Thanks again. &lt;br&gt;
&lt;br&gt;
Amir </description>
    </item>
  </channel>
</rss>

