www.gusucode.com > UWB_matlab源码程序 > CP0804/cp0804_corrsyn.m

    %
% Function 8.15: "cp0804_corrsyn"
%
% Implements the correlation an input vector (signal)
% with a reference vector (template)
% 'fc' represents the sampling frequency
% 
% The function returns the output of the correlator (C)
%
% Programmed by Guerino Giancola
%

function [C] = cp0804_corrsyn(signal,template,fc)

% ----------------------
% Step One - Correlation
% ----------------------

dt = 1 / fc;

for s = 1 : length(signal)
    
    stmp = cp0804_signalshift(template,fc,s*dt);
    % shifted templated waveform
    
    C(s) = sum(signal.*stmp);
    % value of the correlation
    
end % for 1 : length(signal)