Sampling signal in Time domain

16 views (last 30 days)
marwa mohamed
marwa mohamed on 5 Aug 2020
Commented: marwa mohamed on 18 Aug 2020
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
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).
  5 Comments
Antonio Ciociola
Antonio Ciociola on 14 Aug 2020
It seems quite different from the starting question...Could you send the entire code?
marwa mohamed
marwa mohamed on 18 Aug 2020
Dear Antonio Ciociola,
sorry for the late answer, this is the point, i don't know how to do it actually!!
in Python it should be something like that:
x = gauss
X = ft(x(t), Fs, -tstart)
def showModulation(f0):
plt.gcf().clear()
xf0 = lambda t: np.exp(2j*np.pi*f0*t) * x(t)
plt.subplot(121)
plt.plot(t, x(t), label='$x(t)$')
plt.plot(t, xf0(t).real, label=r'Re $\exp(j2\pi f_0t)x(t)$')
plt.plot(t, xf0(t).imag, label=r'Im $\exp(j2\pi f_0t)x(t)$')
plt.subplot(122)
Xf0 = ft(xf0(t), Fs, -tstart)
plt.plot(f, X.real, label='Re $X(f)$')
plt.plot(f, Xf0.real, label='Re $X(f-f_0)$')
and according to the theoretical theorem:
Modulation means multiplying a signal with a complex exponential. In the Fourier Transform, modulating a signal in time domain corresponds to shifting it in the frequency domain. As such, it is the counterpart of shifting in the time domain (which corresponds to modulation in frequency domain). Mathematically, we have
F{exp(j2πf0t)x(t)}=X(ff0).
I have no idea why do i have a circular shift by applying this rule?
Thanks in advance!

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!