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

8 visualizaciones (últimos 30 días)
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 comentario
Walter Roberson
Walter Roberson el 20 de Sept. de 2015
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?

Iniciar sesión para comentar.

Respuesta aceptada

Hamoon
Hamoon el 12 de Sept. de 2015
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 comentarios
Image Analyst
Image Analyst el 12 de Sept. de 2015
Hamoon's code produces this (if you replace the figure calls with calls to subplot):
Hamoon
Hamoon el 12 de Sept. de 2015
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:

Iniciar sesión para comentar.

Más respuestas (1)

claudio
claudio el 20 de Sept. de 2015
Thank you so much, guys. Codes worked like a charm.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by