Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: solving coupled harmonic oscillators using ode45
Replies: 2   Last Post: Jan 30, 2013 8:51 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Torsten

Posts: 1,440
Registered: 11/8/10
Re: solving coupled harmonic oscillators using ode45
Posted: Jan 30, 2013 8:51 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Markus" wrote in message <keb2j0$1a3$1@newscl01ah.mathworks.com>...
> Hello everyone,
>
> I'm trying to solve the problem of three coupled oscillators using the ode45 solver:
>
> ||||---------o----------o-----------o----------||||
>
> The problem that I have is that the system is diverging, after some time, which I do not understand. I think the reason for it is a numerical issue. Maybe someone have an idea. Here is what I tried so far:
>
> --------------------------------------------------------------------------------------------------
>
> function main
> options = odeset('RelTol',1e-8,'AbsTol',1e-8,'MaxStep',0.01);
> [T2,Y2]=ode45(@osz3,0:.05:500,[0.1 0 0 0 0 0],options);
> plot(T2,Y2(:,1:end/2))
> end
>
> function dy = osz3(t,y)
> m = 1;
> D1 = 8;
> D2=1;
> D3=1;
> D4=8;
>
> dy = zeros(6,1); %
> dy(1) = y(4);
> dy(2) = y(5);
> dy(3) = y(6);
> dy(4) =( -D1*y(1)+D2*(y(2)-y(1)))/m;
> dy(5) =(-D2*(y(2)-y(1)+D3*(y(3)-y(2))))/m;
> dy(6) =( -D4*y(3)-D3*(y(3)-y(2)))/m;
>
> end
> ---------------------------------------------------------------------------------------------------
>
> Thank you in advance for any answer.


Write your system of ODEs as
y'=A*y
and determine the eigenvalues of the matrix A.

help eig

Best wishes
Torsten.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.