필터 지우기
필터 지우기

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
Image Analyst
Image Analyst 2015년 9월 12일
Hamoon's code produces this (if you replace the figure calls with calls to subplot):
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.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by