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; error('Need all input arguments'); end;
0023 [N,C]=size(data);
0024 NE=length(E);
0025 winl=win(1);
0026 winr=win(2);
0027 if nargin < 5; t=[0:length(data)-1]/Fs;end
0028 datatmp=[];
0029 for n=1:NE;
0030     indx=find(t>=E(n)-winl & t<E(n)+winr);
0031     datatmp=[datatmp data(indx)];
0032 end;
0033 data=datatmp;

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