0
$\begingroup$

Although some questions were asked about this topic, I have not seen any that answers all the basic questions, that is why I took the liberty to ask more about this.

I suggest to limit, (or at lest to start by), 1D signals. Of course if someone wants to extend they are welcome.

For example, in some lectures it is mentioned that

  • an ideal 1D interpolator is an upsampler (by the wanted factor, e.g. 2) in cascade with an ideal lowpass filter i.e. an sinc.

  • Decimation would be to opposite. A convolution with a filter (sinc?) then a downsampler (by the wanted factor e.g. 2).

In Matlab, given a sine wave at a given frequency for example, how would you proceed to downsample it to a lower frequency? And could you make the link with aliasing ?

I have started to do the following, "manually" coded:

    %Working with audio frequencies, for example,
    %to listen the results with audioread() function afterwards
Fs=8000;%sampling frequency
t=0:(1/Fs):1;
f=4000;
x=sin(2*pi*f*t);
x_dwnsamp=zeros(length(x));
%decimate x to see what happends wrt aliasing
decimation_step=2;
for i=1:decimation_step:length(x)
   x_dwnsamp(i)=x(i);
end
figure;
subplot(1,2,1);
plot(abs(fft(x)));
subplot(1,2,2);
plot(abs(fft(x_dwnsamp)));

This was an attempt to resample the signal x which is just at the Nyquist freq. (4KHz) fora sampling freq. of 8KHz.

$\endgroup$
1
$\begingroup$

There are few problems in the code and question.

In your question 'given a sine wave at a given frequency for example, how would you proceed to downsample it to a lower frequency' this statement is not right. We are not reducing the frequency of sinewave, we are reducing the sampling frequency with which we sampled it.

Second, the code just inserts zeros alternatively. It doesn't downsample (means remove those samples altogether). This means, it is still sampled with original sampling frequency (8kHz) but now with alternate zeros. And what is the effect of alternate zeros in signal? It creates a replica of spectrum. Also, in the code, the signal frequency is exactly half of sampling frequency, which causes sampling to happen at zero crossings. You can plot the signal $x$ and see.

In the code, I changed $f$ to 3000, and can see 2 peaks at 3000Hz and 5000 ($fs - f$)Hz. For the downsampled signal, apart from original signal, there is 2 peaks corresponding to replicated spectrum.

$\endgroup$
  • $\begingroup$ Interesting answer thanks. Could you develop on the idea of downsampling and aliasing i.e. the idea of, given a discrete signal (sampled at a known Fs for example) decimate it should result in a singal with lower frequency e.g. if you have say a cosine with samples 1,-1,1,-1,... if you throw away every second sample you end up with freq=0: 1,1,1,... i.e. no variation $\endgroup$ – Machupicchu Aug 15 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.