# Sample time in convolution

I have a signal sampled at a period of 0.01 and a channel impulse response sampled at 0.1250. I convolved the signal with the channel impulse response.

• It is right to perform the convolution between two signals with diffrent sample times?
• If it is, how can I calculate the sample time of the convolution result?
• "Sampled at NUMBER": do you mean sample period or sample rate? – Marcus Müller Feb 16 at 11:09
• I mean sample period – Nouali Ibrahim Yassine Feb 16 at 11:15

It is right to perform the convolution between two signals with diffrent sample times?

No, aside from a very few special use cases (if you have to ask, not yours), you need to resample either of them so that both are at the same sample rate.

Also notice that sampling a channel impulse response at 8 Hz only gives you information about these 8 Hz (or 4 Hz, depending on whether this is real direct sampling or a sampled equivalent complex baseband representation of the channel). You're trying to apply it to a 100 Hz (or 200 Hz, depending...) wide channel: that won't give you anything useful, even if you resampled. Your channel impulse response measurement simply isn't sufficient.

Convolution does not change the sample rate, but the sample rates of the two inputs need to match. A simple way to do this in your case is to zeropad the spectrum of your signal by a factor of 2 and the spectrum of the channel impulse response by a factor of 25. That way they will both have a sample period of 0.005.

EDIT: There is nothing wrong with this answer. Zeropadding the spectrum of a signal is a simple and common way to change the sample rate. Below is an example using octave.

% FFT function with swapping.
sfft = @(x) fftshift(fft(ifftshift(x)));
sifft = @(x) fftshift(ifft(ifftshift(x)));

% The frequency sample locations for a given
% sample rate and DFT size.
fvec = @(N,fs) (0 : fs/N : (fs-fs/N)).' - (fs - mod(N,2)*fs/N) / 2;

% Parameters for the input signal.
fs1 = 100;                % Sampling frequency (Hz)
T1 = 100;                 % Signal duration (s)
t1 = 0 : 1/fs1 : T1;      % Sample times (s)
N1 = length( t1 );        % Number of input samples
B1 = 0.8 * fs1;           % Signal bandwidth (Hz).
f1 = fvec(N1,fs1);        % Frequency sample locations (Hz)

% Define the some bandlimited random signal.
x1 = sifft( exp(1j*2*pi*rand(N1,1)) .* ( abs(f1) <= B1/2 ) );

% Parameters for the channel impulse response.
fs2 = 8;
T2 = 20;
t2 = 0 : 1/fs2 : T2;
N2 = length( t2 );
B2 = 0.8 * fs2;
f2 = fvec(N2,fs2);

% Some random numbers to represent the channel response.
x2 = sifft( exp(1j*2*pi*rand(N2,1)) .* ( abs(f2) <= B2/2 ) );

% To convolve the input signal with the channel
% impulse response, they both need to be at the
% same sample rate. We do this by zeropadding the
% spectrums of each such that both are sampled
% at the same rate. We use the least common multiple
% so that the zeropad factor is an integer.
fout = lcm( fs1, fs2 );

% The number of samples in the zeropadded spectrums
% for both the input signal and the channel response.
Nzp1 = N1 * fout / fs1;
Nzp2 = N2 * fout / fs2;

% The indices that correspond to the lower
% frequencies. These are the bins into
% which we copy the specrtums.
zinds1 = fvec(N1,N1) + floor( Nzp1/2 ) + 1;
zinds2 = fvec(N2,N2) + floor( Nzp2/2 ) + 1;

% Insert the spectrum into an array of zeros
% and inverse FFT to get the signal at the
% common sample rate.
tmp = zeros( Nzp1, 1 );
tmp( zinds1 ) = sfft( x1 );
x1_out = sifft( tmp );

tmp = zeros( Nzp2, 1 );
tmp( zinds2 ) = sfft( x2 );
x2_out = sifft( tmp );

% Now that both signals have the same sample rate,
% they may be convolved.
y = conv( x1_out, x2_out );

% The frequency sample locations of the convolution.
fy = fvec( length( y ), fout );

figure();
plot( fy, abs( sfft( y ) ) );
xlabel( 'Frequency (Hz)' );
ylabel( 'Amplitude' );
title( 'Spectrum After Convolution' );
xlim( [ -10 10 ] );

• This is not correct. – Dilip Sarwate Feb 16 at 16:28
• What is not correct? Zeropadding the 0.01 signal by two would give a sampling frequency of 200(Hz), while zeropadding the 0.125 channel response by a factor of 25 would likewise yield a sample rate of 200(Hz). – AnonSubmitter85 Feb 16 at 16:34
• Zero-padding in the time domain is different from interpolation. Zero-padding of the DFT in the frequency domain converts the problem to something else entirely. – Dilip Sarwate Feb 16 at 16:37
• Zero-padding in the frequency domain provides an easy way for the OP to match the sample rates of the two inputs, which is what he needs to do if he wants to convolve them. I don't why zeropadding in the time-domain is mentioned. – AnonSubmitter85 Feb 16 at 16:40
• One type of interpolation in the time domain can be achieved by zero-padding the middle portion of the DFT coefficients and performing an inverse DFT. So this answer represents one possible option for solving the problem. If the result is practically useful is a different matter. – Matt L. Feb 16 at 18:40