Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

fvtool

Visualize frequency response of DSP filters

Syntax

fvtool(sysobj)
fvtool(sysobj,options)
fvtool(____,'Arithmetic',arith)

Description

fvtool(sysobj) displays the magnitude response of the filter System object™.

example

fvtool(sysobj,options) displays the response that is specified by the options.

For example, to visualize the impulse response of an FIR filter System object, set options to 'impulse'.

Fs = 96e3; filtSpecs = fdesign.lowpass(20e3,22.05e3,1,80,Fs);
    firlp2 = design(filtSpecs,'equiripple','SystemObject',true);
fvtool(firlp2,'impulse');

fvtool(____,'Arithmetic',arith) analyzes the filter System object, based on the arithmetic specified in arith, using either of the previous syntaxes. You can set arith to 'double', 'single', or 'fixed'. The analysis tool assumes a double-precision filter when the arithmetic input is not specified and the filter System object is unlocked. The 'Arithmetic' property applies only to filter System objects.

For example, to analyze an FIR filter with fixed-point arithmetic, set arith to 'fixed'.

Fs = 96e3; filtSpecs = fdesign.lowpass(20e3,22.05e3,1,80,Fs);
    firlp2 = design(filtSpecs,'equiripple','SystemObject',true);
firlp2.CoefficientsDataType = 'Custom';
firlp2.CustomCoefficientsDataType = numerictype(1,32,30);
fvtool(firlp2,'Arithmetic','fixed');

Examples

collapse all

Create a lowpass halfband decimation filter for data sampled at 44.1 kHz. The output data rate is 1/2 the input sampling rate, or 22.05 kHz. Specify the filter order to be 52 with a transition width of 4.1 kHz.

Fs = 44.1e3;
filterspec = 'Filter order and transition width';
Order = 52;
TW = 4.1e3;
firhalfbanddecim =dsp.FIRHalfbandDecimator('Specification',filterspec, ...
                                              'FilterOrder',Order, ...
                                              'TransitionWidth',TW, ...
                                              'SampleRate',Fs);

Plot the impulse response. The zeroth-order coefficient is delayed 26 samples, which is equal to the group delay of the filter. This yields a causal halfband filter.

fvtool(firhalfbanddecim,'Analysis','impulse')

Plot the magnitude and phase response.

fvtool(firhalfbanddecim,'Analysis','freq')

Create a minimum-order FIR lowpass filter for data sampled at 44.1 kHz. Specify a passband frequency of 8 kHz, a stopband frequency of 12 kHz, a passband ripple of 0.1 dB, and a stopband attenuation of 80 dB.

Fs = 44.1e3;
filtertype = 'FIR';
Fpass = 8e3;
Fstop = 12e3;
Rp = 0.1;
Astop = 80;
FIRLPF = dsp.LowpassFilter('SampleRate',Fs, ...
                             'FilterType',filtertype, ...
                             'PassbandFrequency',Fpass, ...
                             'StopbandFrequency',Fstop, ...
                             'PassbandRipple',Rp, ...
                             'StopbandAttenuation',Astop);

Design a minimum-order IIR lowpass filter with the same properties as the FIR lowpass filter. Change the FilterType property of the cloned filter to IIR.

IIRLPF = clone(FIRLPF);
IIRLPF.FilterType = 'IIR';

Plot the impulse response of the FIR lowpass filter. The zeroth-order coefficient is delayed by 19 samples, which is equal to the group delay of the filter. The FIR lowpass filter is a causal FIR filter.

fvtool(FIRLPF,'Analysis','impulse')

Plot the impulse response of the IIR lowpass filter.

fvtool(IIRLPF,'Analysis','impulse')

Plot the magnitude and phase response of the FIR lowpass filter.

fvtool(FIRLPF,'Analysis','freq')

Plot the magnitude and phase response of the IIR lowpass filter.

fvtool(IIRLPF,'Analysis','freq')

Calculate the cost of implementing the FIR lowpass filter.

cost(FIRLPF)
ans = 

  struct with fields:

                  NumCoefficients: 39
                        NumStates: 38
    MultiplicationsPerInputSample: 39
          AdditionsPerInputSample: 38

Calculate the cost of implementing the IIR lowpass filter. The IIR filter is more efficient to implement than the FIR filter.

cost(IIRLPF)
ans = 

  struct with fields:

                  NumCoefficients: 18
                        NumStates: 14
    MultiplicationsPerInputSample: 18
          AdditionsPerInputSample: 14

Calculate the group delay of the FIR lowpass filter.

grpdelay(FIRLPF)

Calculate the group delay of the IIR lowpass filter. The FIR filter has a constant group delay (linear phase), while its IIR counterpart does not.

grpdelay(IIRLPF)

Input Arguments

collapse all

Input filter, specified as a System object.

Example: firFilt = dsp.FIRFilter('Numerator', fir1(130, 2000/(8000/2)));

Filter analysis options, specified as one of the following:

  • 'magnitude' –– Magnitude response

  • 'phase' –– Phase response

  • 'freq' –– Frequency response

  • 'grpdelay' –– Group delay

  • 'phasedelay' –– Phase delay

  • 'impulse' –– Impulse response

  • 'step' –– Step response

  • 'polezero' –– Pole zero plot

  • 'coefficients' –– Coefficients vector

  • 'info' –– Filter information

  • 'magestimate' –– Magnitude response estimate

  • 'noisepower' –– Round-off noise power spectrum

Example: fvtool(firFilt,'freq');

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: fvtool(sysobj,'Arithmetic','single');

collapse all

Analysis arithmetic used on the filter System object, specified as 'double', 'single', or 'fixed'.

The analysis tool assumes a double-precision filter when the 'Arithmetic' input is not specified and the filter System object is unlocked. This property applies to all filter System objects that you input to fvtool.

Example: firFilt = dsp.FIRFilter('Numerator', fir1(130, 2000/(8000/2))); fvtool(firFilt,'Arithmetic','single');

Introduced before R2006a

Was this topic helpful?