Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Torsten
Posts:
1,457
Registered:
11/8/10


Re: solving coupled harmonic oscillators using ode45
Posted:
Jan 30, 2013 8:51 AM


"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: > > ooo > > 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',1e8,'AbsTol',1e8,'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.



