createdatamatpb

PURPOSE ^

SYNOPSIS ^

function data=createdatamatpb(data,E,Fs,win,t)

DESCRIPTION ^

 Helper function to create an event triggered matrix from a single
 channel of data. 
 Usage: data=createdatamatpb(data,E,Fs,win,t)
 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
 t      (times at which the time series was evaluated in secs) - optional. assume uniform
          grid [0:length(data)-1]/Fs
 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=createdatamatpb(data,E,Fs,win,t)
0002 %
0003 % Helper function to create an event triggered matrix from a single
0004 % channel of data.
0005 % Usage: data=createdatamatpb(data,E,Fs,win,t)
0006 % Inputs:
0007 % data   (input time series as a column vector) - required
0008 % E      (events to use as triggers) - required
0009 % Fs     (sampling frequency of data) - required
0010 % win    (window around triggers to use data matrix -[winl winr]) - required
0011 %          e.g [-1 1] uses a window starting 1 sec before E and
0012 %              ending 1 sec after E if E is in secs
0013 % t      (times at which the time series was evaluated in secs) - optional. assume uniform
0014 %          grid [0:length(data)-1]/Fs
0015 % Note that all times can be in arbitrary units. But the units have to be
0016 % consistent. So, if E is in secs, win, t have to be in secs, and Fs has to
0017 % be Hz. If E is in samples, so are win and t, and Fs=1.
0018 %
0019 % Outputs:
0020 % data      (transformed data)
0021 %
0022 if nargin < 4
0023    error('Need all input arguments'); 
0024 end
0025 N=size(data,1);
0026 NE=length(E);
0027 winl=win(1);
0028 winr=win(2);
0029 if nargin < 5 
0030    t=(0:N-1)/Fs;
0031 end
0032 datatmp=[];
0033 for n=1:NE,
0034     indx=find(t>=E(n)-winl & t<E(n)+winr);
0035     datatmp=[datatmp data(indx)];
0036 end
0037 data=datatmp;

Generated on Fri 20-May-2005 13:10:28 by m2html © 2003