www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/CompareFixedpointFloatingPointExample.m
%% Compare Fixed-point Output with Floating-Point Output % Construct a Lowpass Filter h = dfilt.dffir(firgr(27,[0 .4 .6 1],... [1 1 0 0])); %% % Set h to use fixed-point arithmetic to filter. % Quantize the coeffs. h.arithmetic = 'fixed'; %% % Cast h to double-precision hd = double(h); %% % Set up an input signal. n = 0:99; x = sin(0.7*pi*n(:)); %% % Fixed-point output. y = filter(h,x); %% % Floating-point output. yd = filter(hd,x); %% % Compare the Fixed-point output with Floating-point output FixedFloatNormDiff=norm(yd-double(y),inf)