clear all %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FOr exploring different detunings and couplings detuning=2.5; % detuning between oscillators (in Hz) coupling=1; % interaction strength between oscillators try e.g. 1 noise_level =0.02; % 0.02 % if you like you can add phase noise %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% simulation_time=5; % in sec %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% dt=0.001; phases = zeros(2,simulation_time./dt); K= [ coupling coupling].*dt;%coupling matrix (here symmetric) W= [40 40+detuning].*dt; W=W.*(2*pi); %radians per sec K=K.*(2*pi); %scaling of coupling %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% for time=2:simulation_time./dt %%% SIMULATION of the phase-oscillators %%%%%%%%%% gh=(sin(1.*(phases(1,time-1) -phases(2,time-1)))) ; % PRC phases(1,time)= phases(1,time-1) + (W(1)+ (K(1)*-gh ) )+randn(1).*noise_level ; phases(2,time)= phases(2,time-1) + (W(2)+ (K(2)* gh ) ) +randn(1).*noise_level ; end ph= (mod(phases',2*pi))'; px=angle(exp(1i*ph(1,:))./exp(1i*ph(2,:)));% instant. phase-relation figure('Color','w','Position' ,[ 200 200 1100 250]), subplot(1,3,1,'Fontsize',17) % [ n,c]=hist(px,20);bar(c,n./sum(n)) h = findobj(gca,'Type','patch'); set(h,'FaceColor','k','EdgeColor', [ 0.3 0.3 0.3]) xlim([ -pi pi]);xlabel( 'phase-relation');ylabel('probability') ylim([ 0 0.4]) title( [ 'PLV = ' num2str(abs(mean(exp(1i*px)))) ] ) subplot(1,3,[2 3],'Fontsize',17) % plot(px,'k','Linewidth',2) ylim([ -pi pi]) ylabel('phase_relation (rad) ') xlabel('Time (ms) ')