fft_demo.asv

来自「数字信号处理(机械工业出版社)的源码」· ASV 代码 · 共 26 行

ASV
26
字号
% fft demo
t = 0:.001:.25;
% creat signal
x = sin(2*pi*50*t) + sin(2*pi*120*t);
% add noise and show it
y = x + 2*randn(size(t));
subplot(221)
plot(y(1:50)), title('Noisy time domain signal')
% Power spectral density
Y = fft(y,256);
Pyy = Y.*conj(Y)/256;
f = 1000/256*(0:127);
subplot(222)
plot(f,Pyy(1:128)), 
% Zoom in and plot only up to 200 Hz. 
subplot(223)
plot(f(1:50),Pyy(1:50)), 
title('Power spectral density'), 
xlabel('Frequency (Hz)'),
subplot(224)
title('Power spectral density'), 
xlabel('Frequency (Hz)'), 
plot(f(1:50),Pyy(1:50)), 
title('Power spectral density'), 
xlabel('Frequency (Hz)'), 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?