2 % floating point index - interpolates data in case of non-integer indices
5 % FLIX returns Y=D(x) if x is an integer
6 % otherwise D(x) is interpolated from the neighbors D(ceil(x)) and D(floor(x))
9 % (1) discrete Dataseries can be upsampled to higher sampling rate
10 % (2) transformation of non-equidistant samples to equidistant samples
11 % (3) [Q]=flix(sort(D),q*(length(D)+1)) calculates the q-quantile of data series D
13 % FLIX(D,x) is the same as INTERP1(D,X,'linear'); Therefore, FLIX might
14 % become obsolete in future.
16 % see also: HIST2RES, Y2RES, PLOTCDF, INTERP1
18 % $Id: flix.m 5090 2008-06-05 08:12:04Z schloegl $
19 % Copyright (C) by 2001-2005,2008 Alois Schloegl <a.schloegl@ieee.org>
20 % This is part of the TSA-toolbox see also:
21 % http://www.dpmi.tu-graz.ac.at/schloegl/matlab/tsa/
22 % http://octave.sf.net/
24 % This program is free software: you can redistribute it and/or modify
25 % it under the terms of the GNU General Public License as published by
26 % the Free Software Foundation, either version 3 of the License, or
27 % (at your option) any later version.
29 % This program is distributed in the hope that it will be useful,
30 % but WITHOUT ANY WARRANTY; without even the implied warranty of
31 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 % GNU General Public License for more details.
34 % You should have received a copy of the GNU General Public License
35 % along with this program. If not, see <http://www.gnu.org/licenses/>.
40 k1 = ((x >= 1) & (x <= size(D,1)));
43 k = x - floor(x); % distance to next sample
45 ix = ~k & k1; % find integer indices
46 Y(ix) = D(x(ix)); % put integer indices
48 ix = k & k1; % find non-integer indices
50 Y(ix) = D(floor(x(ix))).*(1-k(ix)) + D(ceil(x(ix))).*k(ix);