MATLAB设计FIR滤波器
%clear;
% fs = 60000000; %采样频率
% f1 = 10000;
% f2 = 4000000;
% w1 = 2*pi*f1/fs; %角频率
% w2 = 2*pi*f2/fs;
% bits = 16;
% n = 0:0.01:500;
% y = sin(w1*n) + sin(w2*n);
% subplot(2,1,1);
% plot(y);
% Y=filter(Num, 1, y); % 实现数字滤波
% %Y = conv(Num1,y);
% subplot(2,1,2);
% plot(Y);
% fc1 = 1000000;
% fc2 = 3000000;
% w1=2*fc1/Fs; w2=2*fc2/Fs;%将模拟滤波器的技术指标转换为数字滤波器的技术指标
% c = 125;
% window=hamming(c+1);%使用hamming窗函数
% b=fir1(c,[w1 w2],window);%使用标准频率响应的加窗设计函数fir1
%freqz(b,1,512);%数字滤波器频率响应
% load Num;
a = max(abs(Num));
b = Num ./ a; %归一化处理
b = fix(b * (2^13)) ;
c = find(b < 0);
b(c) = b(c) + (2^14 ) ; %将滤波器系数量化成整数
% 显示滤波器系数
bb=num2str(b');
for i = 0:1:63;
disp(['parameter ' 'cof' num2str(i) ' = ' '14''d' bb(i+1,:) ';']);
end
% for i = 0:1:63;
% disp([ 'reg [13:0] cof' num2str(i) ';']);
% end
%
% Fs = 60000000;
% f1 = 500000;
% f2 = 6000000;
% t = (0:1:1000)/Fs;
% s = sin(2*pi*t*f1)+sin(2*pi*t*f2) ;%混和正弦波信号
% %s = zeros(1,200)+10;
% %s1= [s, [0 0]];
% %s = 10:0:10;
% figure;
% plot(s);
% sf = filter(b,1,s) %对信号s进行滤波
% figure;
% plot(sf);
% save Num;