Problems in plotting a Sinc signal, applying a FFT with noise and then the IFFT.

8 次查看(过去 30 天)
Hello everyone!
I am trying to plot the signal above, with no success. The code is:
f = 10e3
Ts = 1/(32*f)
n = -160:160
ruido = 2*randn(1,numel(n));
s = sinc(2*pi*f*n*Ts)
%s = sinc(f*n*Ts)
figure
plot (s)
title ('SINC')
xlabel('Tempo (s)')
ylabel ('Amplitude')
x = fft (s);
x = fftshift (s);
fc = [-numel(x)/2:numel(x)/2-1]./numel(x)
figure
plot(fc,fftshift(abs(x)));
title('Transformada de Fourier')
xlabel('Frequencia (Hz)')
ylabel ('Magnitude (dB)')
c = sinc(2*pi*f*n*Ts) + ruido;
figure
plot(c);
title('Sinc com ruido')
xlabel('Frequencia (Hz)')
ylabel ('Magnitude (dB)')
This should be something like this:
But I´m getting this one instead:
Any help is appreciated! Thank you.
  1 个评论
Walter Roberson
Walter Roberson 2015-9-20
What is Ts ? You define it as 1/(32*f) and every time you use it you multiply it by f so the net result is to cancel out the f and Ts and leave just 1/32 . Why ? What does it stand for?

请先登录,再进行评论。

采纳的回答

Hamoon
Hamoon 2015-9-12
You've got some errors in your code, for example, you defined x=fftshift(s) which is wrong. You also add a normally distributed random amount with standard deviation 2, which is larger than the maximum amplitude of sinc function. And also you passed sinc function value without noise to the fft function. I corrected these mistakes, and I tried not to change your code a lot so you can trace the changes, here is the code:
f = 10e3;
Ts = 1/(32*f);
n = -160:160;
noiseSTD = .01;
ruido = noiseSTD*randn(1,numel(n));
s = sinc(2*pi*f*n*Ts);
c = sinc(2*pi*f*n*Ts) + ruido;
%s = sinc(f*n*Ts)
figure
plot (s)
title ('SINC')
xlabel('Tempo (s)')
ylabel ('Amplitude')
x = fft (c);
x = fftshift (abs(x));
fc = (-numel(x)/2:numel(x)/2-1)./numel(x);
figure
plot(fc,x);
title('Transformada de Fourier')
xlabel('Frequencia (Hz)')
ylabel ('Magnitude (dB)')
figure
plot(c);
title('Sinc com ruido')
xlabel('Frequencia (Hz)')
ylabel ('Magnitude (dB)')
  2 个评论
Hamoon
Hamoon 2015-9-12
Yes. thank you Image Analyst. But I just tried to fix obvious mistakes here. he still needs to change some parameters. The result without noise would be like this:

请先登录,再进行评论。

更多回答(1 个)

claudio
claudio 2015-9-20
Thank you so much, guys. Codes worked like a charm.

标签

Community Treasure Hunt

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

Start Hunting!

Translated by