f2 = double(f1) casts
coefficients in a digital filter, f1, to double
precision and returns a new digital filter, f2,
that contains these coefficients.
Use designfilt to design a 5th-order FIR lowpass filter. Specify a normalized passband frequency of rad/sample and a normalized stopband frequency of rad/sample.
Cast the filter to single precision and cast it back to double precision. Display the first coefficient of each filter.
format long
d = designfilt('lowpassfir','FilterOrder',5, ...'PassbandFrequency',0.2,'StopbandFrequency', 0.55);
e = single(d);
f = double(e);
coed = d.Coefficients(1)
coed =
0.003947882145754
coee = e.Coefficients(1)
coee = single
0.0039479
coef = f.Coefficients(1)
coef =
0.003947881981730
Use double to analyze, in double precision, the effects of single-precision quantization of filter coefficients.
f1 — Single-precision digital filter digitalFilter object
Single-precision digital filter, specified as a digitalFilter object.
Use designfilt to generate
a digital filter based on frequency-response specifications and single to cast it to single precision.
Example: f1= single(designfilt('lowpassfir','FilterOrder',3,'HalfPowerFrequency',0.5)) specifies
a third-order Butterworth filter with normalized 3-dB frequency 0.5π
rad/sample cast in single precision.