% Example 1: Generate a pair of Poisson spike trains with % a Gaussian cross-correlation % To call this function from Matlab, just type Example1 % into the command line and press enter. % This program might take a while to run because % computing cross-correlation functions takes a % while. % First define some parameters: rate=.3; % Rate of the processes T=1000000; % Total length of each process dt=.1; % bin size winrad=20; % window radius over which to compute and % plot the cross-correlation % Create the first Poisson spike train p1=Poisson(rate,T,dt); % Now create the second spike train by jittering % the first with random numbers pulled from the % distribution w % Pay attention to the syntax for passing the function % handle to jitter. It's a bit tricky. p2=jitter(p1,@()(4*randn),dt); % Calculate the cross-correlation function % cc12 is the cc function and tau is its domain [cc12,tau]=cross_corr(p1,p2,winrad,dt); % Now plot the cross-correlation function % Bar graphs work well for this data (since % it is basically a normalized histogram) close; bar(tau,cc12); xlabel('time'); ylabel('cross-correlation'); axis([-winrad winrad 0 max(cc12)]);