12.07.2015 Views

Dynamical Systems in Neuroscience:

Dynamical Systems in Neuroscience:

Dynamical Systems in Neuroscience:

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Solutions to Exercises, Chap. 10 51512. [MATLAB] An example is the file adjo<strong>in</strong>t.mfunction Q=adjo<strong>in</strong>t(F,t,x0)% f<strong>in</strong>ds solution to the Malk<strong>in</strong>’s adjo<strong>in</strong>t equation Q’ = -DF^t Q% at time-po<strong>in</strong>ts t with t(end) be<strong>in</strong>g the period% ’x0’ is a po<strong>in</strong>t on the limit cycle with zero phasetran=3; % the number of skipped cyclesdx = 0.000001; dy = 0.000001; % for evaluation of JacobianQ(1,:)=feval(F,0,x0)’;[t,x] = ode23s(F,t,x0);% <strong>in</strong>itial po<strong>in</strong>t;% f<strong>in</strong>d limit cyclefor k=1:tranQ(length(t),:)=Q(1,:); % <strong>in</strong>itial po<strong>in</strong>t;for i=length(t):-1:2% backward <strong>in</strong>tegrationL = [(feval(F,t(i),x(i,:)+[dx 0])-feval(F,t(i),x(i,:)))/dx,...(feval(F,t(i),x(i,:)+[0 dy])-feval(F,t(i),x(i,:)))/dy];Q(i-1,:) = Q(i,:) + (t(i)-t(i-1))*(Q(i,:)*L);end;end;Q = Q/(Q(1,:)*feval(F,0,x0)); % normalizationAn example of a call of the function is Q=adjo<strong>in</strong>t(’F’,0:0.01:2*pi,[1 0]); withfunction dx = F(t,x);z=x(1)+1i*x(2);dz=(1+1i)*z-z*z*conj(z);dx=[real(dz); imag(dz)];13. [MATLAB] We assume that PRC (ϑ) is given by its truncated Fourier series with unknownFourier coefficients. Then, we f<strong>in</strong>d the coefficients that m<strong>in</strong>imize the difference between predictedand actual <strong>in</strong>terspike <strong>in</strong>tervals. MATLAB file f<strong>in</strong>dprc.m takes the row vector of spikemoments, not count<strong>in</strong>g the spike at time zero, and the <strong>in</strong>put function p(t), determ<strong>in</strong>es thesampl<strong>in</strong>g frequency, the averaged period of oscillation and then calls file prcerror.m to f<strong>in</strong>dPRC.function PRC=f<strong>in</strong>dprc(sp,pp)global spikes p tau n% f<strong>in</strong>ds PRC of an oscillator theta’= 1 + PRC(theta)pp(t)% us<strong>in</strong>g the row-vector of spikes ’sp’ (when theta(t)=0)spikes = [0 sp];p=pp;tau = spikes(end)/length(p) % time step (sampl<strong>in</strong>g period)n=8; % The number of Fourier terms approximat<strong>in</strong>g PRCcoeff=zeros(1,2*n+1); % <strong>in</strong>itial approximationcoeff(2*n+2) = spikes(end)/length(spikes); % <strong>in</strong>itial periodcoeff=fm<strong>in</strong>search(’prcerror’,coeff);a = coeff(1:n) % Fourier coefficients for s<strong>in</strong>b = coeff(n+1:2*n) % Fourier coefficients for cosb0= coeff(2*n+1) % dc termT = coeff(2*n+2) % period of oscillationPRC=b0+sum((ones(floor(T/tau),1)*a).*s<strong>in</strong>((tau:tau:T)’*(1:n)*2*pi/T),2)+...sum((ones(floor(T/tau),1)*b).*cos((tau:tau:T)’*(1:n)*2*pi/T),2);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!