MATLAB Answers

Aniket
0

How to implement coupled ordinary differential equations in Matlab

Asked by Aniket
on 13 Jan 2013
Latest activity Edited by Shritej Chavan on 19 May 2018 at 1:53

I am trying to implement adaptive hopf oscillator.

i have to implement these dynamics eqution

dx/dt = (mu - r^2)x - wy +KF(t)

dy/dt = (mu - r^2)y + wx

where , mu = 1 and initial condition of r(0)= 1 (r = root(x^2 + y^2))

F(t) is time periodic perturbation means any input signal and K is coupling strength , w is intrinsic frequency of oscillator

learning rule for this adaptation is

dw/dt = -KF(t) * [y/(root (x^2+y^2))]

  0 Comments

Sign in to comment.

2 Answers

Answer by Azzi Abdelmalek
on 13 Jan 2013
Edited by Azzi Abdelmalek
on 13 Jan 2013
 Accepted Answer

function dz=myeqd(t,y,ti,fi)
mu=0.7;
r=1;
K=1;
w=1;
F=interp1(ti,fi,t);
dz(1)= (mu - r^2)*y(1) - w*y(2) +K*F;
dz(2) = (mu - r^2)*y(2) + w*y(1);

Then call the above function

ti=[0.1:0.1:10]; % time vector
fi=rand(1,numel(t)); % your perturbation
t=ti;
[t,y]=ode45(@(t,y) dif_eq(t,y,ti,fi),t,[0;0]);

  2 Comments

Hello Azzi,

Thank you for your answer and still small doubt that....i want to implement adaptive hopf oscillator so that oscillator frequency(w) learn the perturbation signal (F) frequency ...so that they have given the learning rule for this learning rule for this adaptation is

dw/dt = -KF(t) * [y/(root (x^2+y^2))]

so how should i implement this state variable with above code?

thank you.

function dz = myeqd(t,x,fi,ti, epsilon, mu, gamma, eta) 
%gamma - speed  of convergence
%mu - radius of limit cycle 
%epsilon & eta - coupling constant
F_t = interp1(ti,fi, t);
k = gamma*(mu - (x(1)^2 + x(2)^2))*x(1) - x(3)*x(2) + epsilon*(F_t) ;
y = gamma*(mu - (x(1)^2 + x(2)^2))*x(2) + x(3)*x(1) ;
w = -epsilon*(F_t)*x(2)/(x(1)^2 + x(2)^2) ; 
a = eta*x(1)*(F_t);
dz = [k;y;w;a] ; 
end 

In the command window

ti = 0:0.1:2000 ;
t = ti ;
fi = sin(40*t) ;
[t,x] = ode45(@(t,x)myeqd(t,x,fi,ti,0.9, 1,17, 0.9), t , [1 0 45 1] ) ; 

*The problem is the amplitude does not converge to a proper value but the frequency does and the amplitude keeps increasing after time when the oscillator has learned the correct frequency.

Sign in to comment.


Answer by Teratora
on 11 Mar 2015

Hi,

It's been a long time since this was posted and I was wondering if you had finally made it work Aniket, as I am trying to do exactly that right now. I'm going to try coupling several adaptive Hopf oscillators, but need to start with the beginning, right? ;-)

Hope you'll answer! Thanks =)

  2 Comments

I found some MATLAB example files for Hopf bifurcation that might help you get started

http://www.isnld.com/indexC.html

Hi Teratora,

It's been a long time since you asked this question and I was wondering if you really implemented network coupled adaptive Hopf oscillators. I am trying to do exactly that right now. I am copying your words but I am serious. I am struggling and I need help.

Hope you will answer! Thanks in advance .

Sign in to comment.


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today