## Copyright (C) 2018 Jens Ahrensfeld ## ## 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 . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{retval} =} gardner_eval (@var{input1}, @var{input2}) ## ## @seealso{} ## @end deftypefn ## Author: Jens Ahrensfeld ## Created: 2018-12-13 function gardner_eval (x, nBitsPerSample, phase) if mod(nBitsPerSample, 2) error ("nBitsPerSample must be divisable by 2!"); end Z = zeros(1,3); countReload = nBitsPerSample/2; count = countReload-1; N = length(x); vc = 0; k = 1; for n=1:N, if count == phase Z = [x(n) Z(1:2)]; vc = Z(2) * (Z(3) - Z(1)); _y(k) = x(n); k = k + 1; end if count == 0 count = countReload-1; else count = count - 1; end _vc(n) = vc; end subplot(2,1 ,1) plot(1:N, _vc); grid; subplot(2,1 ,2) plot(1:k-1, _y, '-o'); grid; endfunction