X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=octave_packages%2Ftsa-4.2.4%2Fflix.m;fp=octave_packages%2Ftsa-4.2.4%2Fflix.m;h=a53dee028e5ca034ed289a121140869e90c896ba;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hp=0000000000000000000000000000000000000000;hpb=1705066eceaaea976f010f669ce8e972f3734b05;p=CreaPhase.git diff --git a/octave_packages/tsa-4.2.4/flix.m b/octave_packages/tsa-4.2.4/flix.m new file mode 100644 index 0000000..a53dee0 --- /dev/null +++ b/octave_packages/tsa-4.2.4/flix.m @@ -0,0 +1,51 @@ +function Y=flix(D,x) +% floating point index - interpolates data in case of non-integer indices +% +% Y=flix(D,x) +% FLIX returns Y=D(x) if x is an integer +% otherwise D(x) is interpolated from the neighbors D(ceil(x)) and D(floor(x)) +% +% Applications: +% (1) discrete Dataseries can be upsampled to higher sampling rate +% (2) transformation of non-equidistant samples to equidistant samples +% (3) [Q]=flix(sort(D),q*(length(D)+1)) calculates the q-quantile of data series D +% +% FLIX(D,x) is the same as INTERP1(D,X,'linear'); Therefore, FLIX might +% become obsolete in future. +% +% see also: HIST2RES, Y2RES, PLOTCDF, INTERP1 + +% $Id: flix.m 5090 2008-06-05 08:12:04Z schloegl $ +% Copyright (C) by 2001-2005,2008 Alois Schloegl +% This is part of the TSA-toolbox see also: +% http://www.dpmi.tu-graz.ac.at/schloegl/matlab/tsa/ +% http://octave.sf.net/ +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see . + +D = D(:); +Y = x; + +k1 = ((x >= 1) & (x <= size(D,1))); +Y(~k1) = NaN; + +k = x - floor(x); % distance to next sample + +ix = ~k & k1; % find integer indices +Y(ix) = D(x(ix)); % put integer indices + +ix = k & k1; % find non-integer indices + +Y(ix) = D(floor(x(ix))).*(1-k(ix)) + D(ceil(x(ix))).*k(ix); +