www.gusucode.com > signal 案例源码程序 matlab代码 > signal/LowpassFIRFilterInSingleAndDoublePrecisionExample.m

    %% Lowpass FIR Filter in Single and Double Precision
% Use |designfilt| to design a 5th-order FIR lowpass filter. Specify a
% normalized passband frequency of $0.2\pi$ rad/sample and a normalized
% stopband frequency of $0.55\pi$ rad/sample.
%
% Cast the filter to single precision and cast it back to double precision.
% Display the first coefficient of each filter.

% Copyright 2015 The MathWorks, Inc.


%%

format long
d = designfilt('lowpassfir','FilterOrder',5, ...
               'PassbandFrequency',0.2,'StopbandFrequency', 0.55);
e = single(d);
f = double(e);

coed = d.Coefficients(1)
coee = e.Coefficients(1)
coef = f.Coefficients(1)

%%
% Use |double| to analyze, in double precision, the effects of
% single-precision quantization of filter coefficients.