Problems in plotting a Sinc signal, applying a FFT with noise and then the IFFT.
2 ビュー (過去 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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148944/image.bmp)
But I´m getting this one instead:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148946/image.jpeg)
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):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/181205/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/181206/image.jpeg)
その他の回答 (1 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!