createdatamatc

PURPOSE ^

Helper function to create an event triggered matrix from a single

SYNOPSIS ^

function data=createdatamatc(data,E,Fs,win)

DESCRIPTION ^

 Helper function to create an event triggered matrix from a single
 channel of data. 
 Usage: data=createdatamatc(data,E,Fs,win)
 Inputs:
 data   (input time series as a column vector) - required
 E      (events to use as triggers) - required 
 Fs     (sampling frequency of data) - required
 win    (window around triggers to use data matrix -[winl winr]) - required 
          e.g [-1 1] uses a window starting 1 sec before E and
              ending 1 sec after E if E is in secs.
 Note that all times can be in arbitrary units. But the units have to be
 consistent. So, if E is in secs, win, t have to be in secs, and Fs has to
 be Hz. If E is in samples, so are win and t, and Fs=1.

 Outputs:
 data      (transformed data)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function data=createdatamatc(data,E,Fs,win)
0002 % Helper function to create an event triggered matrix from a single
0003 % channel of data.
0004 % Usage: data=createdatamatc(data,E,Fs,win)
0005 % Inputs:
0006 % data   (input time series as a column vector) - required
0007 % E      (events to use as triggers) - required
0008 % Fs     (sampling frequency of data) - required
0009 % win    (window around triggers to use data matrix -[winl winr]) - required
0010 %          e.g [-1 1] uses a window starting 1 sec before E and
0011 %              ending 1 sec after E if E is in secs.
0012 % Note that all times can be in arbitrary units. But the units have to be
0013 % consistent. So, if E is in secs, win, t have to be in secs, and Fs has to
0014 % be Hz. If E is in samples, so are win and t, and Fs=1.
0015 %
0016 % Outputs:
0017 % data      (transformed data)
0018 %
0019 if nargin < 4; error('Need all arguments'); end;
0020 N=size(data);
0021 NE=length(E);
0022 winl=win(1);
0023 winr=win(2);
0024 npts=round((winr+winl)*Fs);
0025 datatmp=[];
0026 for n=1:NE;
0027     indx=round(linspace(E(n)-winl,E(n)+winr,npts)*Fs);
0028     datatmp=[datatmp data(indx)];
0029 end;
0030 data=datatmp;

Generated on Tue 24-Aug-2004 15:55:33 by m2html © 2003