Sampling signal in Time domain
Show older comments
Dear all,
i have a vector of [1 -1 1 -1 1 -1...] with length of 500. how can i oversample this signal and see the effect of the oversampling in the frequency domain?
i am confused between upsampling and interp? what is the difference?
thanks,
Answers (1)
Antonio Ciociola
on 7 Aug 2020
Edited: Antonio Ciociola
on 8 Aug 2020
It seems that your data has been taken by sampling a sinusoid using a sampling frequency that is only two time the frequency of the sine. Unfortunately, if you want to respect the Nyquist's theorem, you have to respect the following equation.

Anyway, try to run the following example:
close all
N = 500;
fsin = 100;
fsample = 10*fsin;
tsin = 1/fsin;
t = 0:1/fsample:N/fsample;
s =sin(2*pi*t*fsin);
upsampling = 10;
figure; plot(s)
title('Original Signal')
faxis = -0.5*fsample:fsample/N:0.5*fsample-1/N;
sF = (1/length(s))*(fft(s));
sFPad = [sF(1:round(0.5*length(sF))) zeros(1,(upsampling-1)*length(sF)) sF(round(0.5*length(sF))+1:end) ];
ss = (length(sFPad))*(ifft((sFPad)));
tss = t(end)*linspace(0,1,length(ss));
figure; plot(ss)
title('Signal after upsampling')
As you can see, after the padding the anti-transformed signal it's the oversampled version of the original signal.
After the zero padding, there is more "distance" (in the frequency domain) between the two peak of the original tone. This is the same effect that you get if you try to increase the sampling frequency of the original signal.
Now you can get the same result if you keep the same sampling frequency and try to put a zero between every sample of the original signal (zero interleaving) and then try to do a filtering in time domain.
So upsampling in frequency domain (zero padding with filtering) <--> upsampling in time domain (zero interleaving with filtering).
You can find other useful information here: https://www.dsprelated.com/freebooks/sasp/Upsampling_Downsampling.html
5 Comments
marwa mohamed
on 11 Aug 2020
Antonio Ciociola
on 14 Aug 2020
Edited: Antonio Ciociola
on 14 Aug 2020
I'll try to clarify my answer.
"i have a vector of [1 -1 1 -1 1 -1...] with length of 500. how can i oversample this signal and see the effect of the oversampling in the frequency domain?"
A vector of [1 -1 1 -1 1 -1...] it's a sine wave sampled using two samples in a period (Fsample = 2*fsinewave).
You can see it by running the following code:
N = 500;
fsin = 100;
fsample = 2*fsin;
tsin = 1/fsin;
t = 0:1/fsample:N/fsample;
s =sin(2*pi*t*fsin + pi*0.5);
upsampling = 10;
figure; plot(s)
title('Original Signal')
Using the upsample function in this way:
y = upsample(s,K)
You're goin to put K-1 zeros between every sample of the original signal (and this is equal to zero padding in frequency domain)
You should see the effect of this operation in the time domain by verifying that k-1 zeros are added at the end of the fft in frequency domain.
Try to perform the operation on a simple (and maybe short) signal and look what you get.
marwa mohamed
on 14 Aug 2020
Antonio Ciociola
on 14 Aug 2020
It seems quite different from the starting question...Could you send the entire code?
marwa mohamed
on 18 Aug 2020
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!