#pragma rtGlobals=1 // Use modern global access method. // Function for running the simulation. Function GerkinSimulate(ctrlName) String ctrlName // Access all the global variables (the simulation parameters) SetDataFolder root:Parameters NVar duration // in milliseconds. NVar frequency // stimulus frequency in Hz. NVar pulse_width // width of the pulse (AB or BA) in milliseconds. NVar ab_on,ba_on NVar timing // The timing in between doublets, ba - ab, in milliseconds. NVar dt // Simulation time-scale, in milliseconds. NVar p_off,d_off,v_off,lambda,p_steep,d_steep,w_off,NR2A,NR2B // Initialize the waves that track the evolution of the dynamics variables. SetDataFolder root: Variable time_steps=duration/dt Make /o /n=(time_steps) AB_=0,BA_=0,P_=0,D_=0,V_=0,W_=0 SetScale /P x,0,dt,AB_,BA_,P_,D_,V_,W_ Variable t // Tracks time in milliseconds. // Set stimulus waves AB and BA according to the parameters. Variable thyme=1000/(2*frequency) Variable point_timing=round(timing/dt) Variable point_width=round(pulse_width/dt) for(t=0;t1000/frequency) AB_[t,t+point_width-1]=ab_on ? 1 : 0 BA_[t+point_timing,t+point_timing+point_width-1]=ba_on ? 1 : 0 thyme=0 endif endfor // Run simulation. for(t=1;t