firfiltercoef.m

来自「CHP 4 - Real-Time Digital Signal Process」· M 代码 · 共 36 行

M
36
字号
% 
%  Project: Example 4.18: floating-point implementation of FIR filter - Chapter 4
%  File name: firFilterCoef.m   
%
%  Description: This MATLAB script generates the FIR coefficients
%               and use the filter on a given input data
%
%  For the book "Real Time Digital Signal Processing: 
%                Implementation and Application, 2nd Ed"
%                By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
%                Publisher: John Wiley and Sons, Ltd
%
%
% Write for MATLAB v 7.01
%

fid = fopen('..\\data\\input.pcm', 'r');
in = fread(fid, 'int16');
f=[0 0.3 0.4 0.5 0.6 1];
m=[0 0 1 1 0 0 ];
b=remez(47, f, m);
[h, omega]=freqz(b,1,512);
plot(f,m,omega/pi, abs(h));

y=filter(b, 1, in/32767.0);
p=spectrum(y, 128);
p2=spectrum(in, 128);

figure(1);
plot(20*log10(abs(p)));
grid;
figure(2);
plot(20*log10(abs(p2)));
grid;
fclose(fid);

⌨️ 快捷键说明

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