Products & Services Solutions Academia Support User Community Company

Learn more about Filter Design Toolbox   

double - Cast fixed-point filter to use double-precision arithmetic

Syntax

hd = double(h)

Description

hd = double(h) returns a new filter hd that has the same structure and coefficients as h, but whose arithmetic property is set to double to use double-precision arithmetic for filtering. double(h) is not the same as the reffilter(h) function:

You might find double(h) useful to isolate the effects of quantizing the coefficients of a filter by using double to create a filter hd that operates in double-precision but uses the quantized filter coefficients.

Examples

Use the same filter, once with fixed-point arithmetic and once with floating-point, to compare fixed-point filtering with double-precision floating-point filtering.

h = dfilt.dffir(firgr(27,[0 .4 .6 1],... 
[1 1 0 0]));              % Lowpass filter.
% Set h to use fixed-point arithmetic to filter.
% Quantize the coeffs.
h.arithmetic = 'fixed'; 
hd = double(h);           % Cast h to double-precision 
                          % floating-point coefficients.
n = 0:99; x = sin(0.7*pi*n(:)); % Set up an input signal.
y = filter(h,x);                % Fixed-point output.
yd = filter(hd,x);              % Floating-point output.
norm(yd-double(y),inf)
ans =

  9.2014e-004

norm shows that the largest difference (maximum error) between the output values from the fixed versus floating filtering comparison is about 0.0009 — either good or less good depending on your application.

See Also

reffilter

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS