Sampling signal in Time domain

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

Hey!
Sorry for my late answer, actullay when i am trying to add my original signal it gives me an error at sFPad line... my orignal signal is an m-sequence signal with size of (1536000 1) and not a sine wave. could you please help me. I tried to use upsample function from matlab but it isnt giving me the correct answer
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.
hi,
Actually my signal isnt a sine wave it is a pulses with the values of -1 and 1, i managed to sample it with interp function and it is working fine.
now my proplem is that i want to shift this sampled signal in time domain using frequency... i mean i want to apply the modulation/ Frequency shifting property of the Fourier transform ----> F{exp(j2πf0t)x(t)}=X(f−f0)
by multiplying my signal as the following:
T = (Tc/2)*(0:1:length(Sampled_signal)-1);
SHIFT=2e6;
mult=exp(-1i*2*pi*SHIFT*T);
shiftedsignal=Sampled_signal.*mult';
It gives me a circular shift, but i dont want it to be circular, i just want a normal shift.
Can you help?
It seems quite different from the starting question...Could you send the entire code?
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

Asked:

on 5 Aug 2020

Commented:

on 18 Aug 2020

Community Treasure Hunt

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

Start Hunting!