Problems in plotting a Sinc signal, applying a FFT with noise and then the IFFT.
1 次查看(过去 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
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
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
2015-9-12
Hamoon's code produces this (if you replace the figure calls with calls to subplot):
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!