1 ## Copyright (C) 2000 Paul Kienzle
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
16 ## y = au(x, fs, lo [, hi])
18 ## Extract data from x for time range lo to hi in milliseconds. If lo
19 ## is [], start at the beginning. If hi is [], go to the end. If hi is
20 ## not specified, return the single element at lo. If lo<0, prepad the
21 ## signal to time lo. If hi is beyond the end, postpad the signal to
24 ## TODO: modify prepad and postpad so that they accept matrices.
25 function y=au(x,fs,lo,hi)
26 if nargin<3 || nargin>4,
27 usage("y = au(x, fs, lo [,hi])");
30 if nargin<4, hi=lo; endif
41 if hi<lo, t=hi; hi=lo; lo=hi; endif
42 if (size(x,1)==1 || size(x,2)==1)
43 y=x(max(lo,1):min(hi,length(x)));
44 if (lo<1), y=prepad(y,length(y)-lo+1); endif
45 if (hi>length(x)), y=postpad(y,length(y)+hi-length(x)); endif
47 y=x(max(lo,1):min(hi,length(x)), :);
48 if (lo<1), y=[zeros(size(x,2),-lo+1) ; y]; endif
49 if (hi>length(x)), y=[y ; zeros(size(x,2),hi-length(x))]; endif