% Project Links
% Poisson Demo
% gen_sim.m
% Written by Elisa H. Barney Smith
% March 1996
function [data, time] = gen_sim( w_start, w_end, data_1, Fs1, times)
% Inputs:
% -------
% w_start: time to start generating simulated data for
% w_end: time to end generating simulated data for
% data_1: single pulse at lower sampling rate (Fs1) for momory savings
% and for Sparc playback. (8192 Hz)
% Fs1: sampling frequency of downsampled data
% times: times at which events should occur
% Outputs:
% --------
% time: time axis that corresponds with output data
% data: data that is generated with poisson spacing
% Variables:
% ---------
% times_now: list of event times that are in current time window
% d_start: time that occurs in time sequence where a pulse should start
% ii: loop counter
times_now = times(find((times>=w_start)&(times<=(w_end-length(data_1)/Fs1))));
time = 1:((w_end-w_start)*Fs1);
time = time/Fs1 + w_start;
data = zeros(size(time));
for (ii=1:length(times_now)),
d_start = find(abs(time-times_now(ii)) == min(abs(time-times_now(ii))));
data(d_start:(d_start+length(data_1)-1)) = data_1;
end
data = data+ randn(size(data))/25;