myfft.m
来自「自己定义了一种有关声音的特征」· M 代码 · 共 24 行
M
24 行
function myfft()
N=512*16;
fs=16000;
figure(1);
t = 1/fs:1/fs:1;
x=zeros(size(t));
for i=0:12
x=x+sin(2*pi*261*2^(i/12)*t);
%x = sin(2*pi*261*t)+sin(2*pi*261*2^(1/24)*t)+sin(2*pi*522*t)+sin(2*pi*440*t);
end
y = x + 2*randn(size(t));
plot(fs*t(1:100),y(1:100));
title('Signal Corrupted with Zero-Mean Random Noise');
xlabel('time (milliseconds)');
Y = fft(y,N);
Pyy = Y.* conj(Y) / (N);
%[pcpdata,lodd,leven]=pcp(data,1);
%fprintf('lodd=%d leven=%d\n',lodd,leven);
%Pyy = abs(Y).^2 / 512;
f = fs*(1:fs/2+1)/(N);
figure(2);
plot(f,Pyy(1:fs/2+1));
title('Frequency content of y');
xlabel('frequency (Hz)');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?