# Can someone help me implement my Kuramoto Model with time delay please?

조회 수: 3 (최근 30일)
Newbie 2021년 9월 1일
댓글: Newbie 2021년 9월 2일
Hi there,
I want to solve numerically a system of DDEs with two coupled oscillators based on the Kuramoto Model with a time delay. These are my DDEs:
where K is my coupling matrix. This is the code I am using but I keep getting that not enough inputs and it does not work:
N=2; % two oscillators: melatonin and cortisol
omega=2*pi; % intrinsic frequency of both oscillators: 24 hours
tau=[5*pi/9]; % time delay: 3 hours and 20 minutes
h=0.1; % step size
iter=500; % number of iterations
tspan=0:h:h*iter; % time
K=[0 0.5;0.5 0]; % initialising the coupling matrix
sol=dde23(@ddefun,tau,@history,tspan)
% Subfunctions
thetalag1=Z(:,1);
omega+K(2,1)*sin(thetalag1(1)-theta(2))];
end
function s=history(t)
s=ones(2,1);
end
Please can someone help me and see where I am going wrong?
Thank you.

댓글을 달려면 로그인하십시오.

### 채택된 답변

Fabio Freschi 2021년 9월 2일
편집: Fabio Freschi 2021년 9월 2일
Your function requires additional parameters. One way to pass them is to use an anonymous function as extra layer
% params
N = 2; % two oscillators: melatonin and cortisol
omega = 2*pi; % intrinsic frequency of both oscillators: 24 hours
tau = 5*pi/9; % time delay: 3 hours and 20 minutes
h = 0.1; % step size
iter = 500; % number of iterations
tspan = 0:h:h*iter; % time
K = [0 0.5; 0.5 0]; % initialising the coupling matrix
% extra layer function so that omega and K are available to ddefun
myfun = @(t,theta,Z)ddefun(t,theta,Z,omega,K);
% call to solver
sol = dde23(myfun,tau,@history,tspan);
% Subfunctions
thetalag1 = Z(:,1);
omega+K(2,1)*sin(thetalag1(1)-theta(2))];
end
function s = history(t)
s = ones(2,1);
end
You can find other strategies to pass extra parameters here
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Newbie 2021년 9월 2일
Thank you! It works.

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by