view aim-mat/tools/@signal/convolute.m @ 0:74dedb26614d

Initial checkin of AIM-MAT version 1.5 (6.4.2011).
author tomwalters
date Fri, 20 May 2011 12:32:31 +0100
parents
children 20ada0af3d7d
line wrap: on
line source
% method of class @signal
% function sig=convolute(sig1,sig2)
%
% calculates the convolution between the signals sig1 and sig2. The
% return value is a signal 
%
%   INPUT VALUES:
%       sig1: original @signal
%       sig2: @signal to correlate with
% 		
%   RETURN VALUE:
% 		@sig: the convolution values at each delay
%
% (c) 2003, University of Cambridge, Medical Research Council 
% Stefan Bleeck (stefan@bleeck.de)
% http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual
% $Date: 2003/02/12 19:08:38 $
% $Revision: 1.2 $

function sig=convolute(sig1,sig2)


values1=getvalues(sig1);
values2=getvalues(sig2);

% do the convolution
sr1=getsr(sig1);
sr2=getsr(sig2);

if sr1~=sr2
    error('sample rates of both signals must be the same!');
    return
end

corrcovs=conv(values1,values2);

% return a signal:
sig=signal(corrcovs,sr1);
sig=setname(sig,'Convolution');