
function [x,t,xi] = boxcars(T,fs,len)

% function [x,t,xi] = boxcars(T,fs,len)
%
% Generate boxcar variable
%
% T         Length of time series (secs)
% fs        Sampling rate, (Hz)
% len       Length of top of boxcar (secs)
%
% x         Event stream (1-event, 0-no event) (samples)
% t         time index (secs) eg. for plot(t,x) 
% xi        Sample numbers of events  (samples)
%
% W. Penny, FIL, Aug 2003

N=T*fs;
t=[1/fs:1/fs:T];

L=len*fs;
box=[zeros(L,1);ones(L,1)];
x=zeros(N,1);
xx=repmat(box,floor(N/length(box)),1);
x(1:length(xx))=xx;

xi=find(x==1);



