Matlab中如何使用fdattool
fdatool设置,在matlab输入fdatool
可以保存为函数
文件名称为fir1,生成的m文件内容为
function Hd = fir1
%FIR1 Returns a discrete-time filter object.
% MATLAB Code
% Generated by MATLAB(R) 9.0 and the Signal Processing Toolbox 7.2.
% Generated on: 16-Nov-2018 15:57:29
% Equiripple Lowpass filter designed using the FIRPM function.
% All frequency values are in MHz.
Fs = 90; % Sampling Frequency
Fpass = 1; % Passband Frequency
Fstop = 12; % Stopband Frequency
Dpass = 0.0057563991496; % Passband Ripple
Dstop = 3.1622776602e-06; % Stopband Attenuation
dens = 20; % Density Factor
% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fpass, Fstop]/(Fs/2), [1 0], [Dpass, Dstop]);
% Calculate the coefficients using the FIRPM function.
b = firpm(N, Fo, Ao, W, {dens});
Hd = dfilt.dffir(b);
% [EOF]
2、matlab验证
fs=90e6 ;
N=4096;
n= 0:N-1;
t=n/fs;
f1=41.4e6;
f2=41.45e6;
A=2e15;
X=A*cos(2*pi*f1*t);
Y=A*cos(2*pi*f2*t);
figure(1);
plot(X);
figure(2);
plot(Y);
M=X.*Y;
figure(3);
plot(M)
Hd=fir2;
output = filter(Hd,M);
figure(4);
plot(output)
- 仿真结果
如果只是将采样率设置为为100M,仿真结果,可以看出结果很平滑。
如果将混频的频率换为10.5M和10M,仿真结果为,结果也很光滑。