下面是我收网上的例程修改的,但是不对,请那位帮我改下
Fs = 3200; % 采样率
N = 64; % 采样点数
n = 0:N-1; % 采样序列
t = 0:1/Fs:1-1/Fs; % 时间序列
f = n * Fs / N; %真实的频率
x=[1648,1510,1377,1243,1110,980,858,740,
630,531,441,360,293,239,196,168,
152,148,159,184,221,271,334,406,
489,586,689,805,924,1051,1180,1314,
1448,1583,1718,1851,1976,2099,2219,2330,
2434,2532,2618,2695,2763,2813,2854,2885,
2902,2903,2892,2867,2828,2780,2721,2646,
2565,2471,2372,2264,2147,2022,1897,1767,
];
y = fft(x, N); %对原始信号做FFT变换
Mag = abs(y); %求FFT转换结果的模值
subplot(2,1,1);
plot(f, Mag); %绘制幅频相应曲线
title('幅频相应');
xlabel('频率/Hz');
ylabel('幅度');
subplot(2,1,2);
plot(f, angle(y)*180/pi); %绘制相频响应曲线,注意这将弧度转换成了角度
title('相频响应');
xlabel('频率/Hz');
ylabel('幅度'); |