Main Content

fvtool

(To be removed) Visualize frequency response of DSP filters

Description

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

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");

example

fvtool(____,Name=Value) visualizes the response of the filter with each specified property set to the specified value.

For more input options, see FVTool in Signal Processing Toolbox™.

Examples

collapse all

Create two lowpass halfband decimation filters. The design method in the first filter is set to "Equiripple" and in the second filter is set to "Kaiser".

Specify the filter order to be 52. Specify the transition width in normalized frequency units.

filterspec = "Filter order and transition width";
Order = 52;
TW = 0.1859;
firhalfbanddecimEqui = dsp.FIRHalfbandDecimator(...
    NormalizedFrequency=true,...
    Specification=filterspec,...
    FilterOrder=Order,...
    TransitionWidth=TW,...
    DesignMethod="Equiripple");
firhalfbanddecimKaiser = dsp.FIRHalfbandDecimator(...
    NormalizedFrequency=true,......
    Specification=filterspec,...
    FilterOrder=Order,...
    TransitionWidth=TW,...
    DesignMethod="Kaiser");

Plot the magnitude response. If the filter specifications are tight, say a very high filter order with a very narrow transition width, the filter designed using the "Kaiser" method converges more effectively.

hfvtMag = fvtool(firhalfbanddecimEqui,firhalfbanddecimKaiser);
legend(hfvtMag,["Equiripple","Kaiser"])

Input Arguments

collapse all

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 Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: firFilt = dsp.FIRFilter(Numerator=designLowpassFIR(FilterOrder=130, CutoffFrequency=2000/(8000/2))); fvtool(firFilt,Arithmetic="single")

Sampling rate, specified as a scalar. This value determines the Nyquist interval [-Fs/2 Fs/2] in which the fvtool shows the frequency response of the filters in the channelizer.

Data Types: single | double

Specify the arithmetic used during analysis. 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 set to 'Fixed' applies only to filter System objects with fixed-point properties.

When the 'Arithmetic' property is set to 'Fixed', the tool shows both the double-precision reference filter and the quantized version of the filter. The CoefficientsDataType property in the respective filter System object is used in creating the quantized version of the filter for all the analyses options except for the two below:

  • 'magestimate' –– Magnitude response estimate.

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

For these two analyses options, all the fixed-point settings are used in analyzing the quantized version of the filter.

Version History

Introduced before R2006a

expand all

R2024b: fvtool will be removed

The fvtool function will be removed in a future release. Use filterAnalyzer instead. The fvtool and filterAnalyzer functions perform differently, and using filterAnalyzer requires updates to your code.

Consider these filters:

[b,a] = ellip(5,5,60,[0.2 0.45]);
dFd = dsp.FIRFilter;

This table shows how to update existing code.

Original Code in R2024a or EarlierUpdated Code in R2024b
fvtool(b,a,dFd)
filterAnalyzer(b,a,dFd)
fvtool(b,a,dFd,Analysis="freq")
filterAnalyzer(b,a,dFd,...
Analysis="magnitude",Overlay="phase")
fvtool(b,a,Fs=1000)
filterAnalyzer(b,a,SampleRates=1000)
fvtool(b,a,dFd,NumberofPoints=512, ...
    FrequencyRange="[0, 2pi)",FrequencyScale="Log")
filterAnalyzer(b,a,dFd,NFFT=512, ...
    FrequencyRange="twosided",FrequencyScale="log")
hfvt = fvtool(dFd);
addfilter(hfvt,dfilt.df1(b,a))
fa = filterAnalyzer(dFd);
addFilters(fa,b,a)
hfvt = fvtool(dFd);
setfilter(hfvt,dfilt.df1(b,a))
fa = filterAnalyzer(dFd,FilterNames="df");
replaceFilters(fa,b,a,FilterNames="df")
hfvt = fvtool(b,a,dFd);
deletefilter(hfvt,2)
fa = filterAnalyzer(b,a,dFd,FilterNames=["ba" "dFd"]); 
deleteFilters(fa,FilterNames="dFd")
hfvt = fvtool(b,a,dFd);
legend(hfvt,"ba","dFd")
filterAnalyzer(b,a,dFd,FilterNames=["ba" "dFd"])
hfvt = fvtool(b,a,dFd);
zoom(hfvt,[0.4 0.7 -30 0])
fa = filterAnalyzer(b,a,dFd);
zoom(fa,"xy",[0.4 0.7 -30 0])
fvtool(b,a,dFd,Analysis="noisepower")
filterAnalyzer(b,a,dFd,Analysis="noisepsd")

The second order sections (SOS) format is not supported in Filter Analyzer. Use the CTF format instead. Given a filter specified as an SOS matrix sos, you must make the following updates to your code.

Original Code in R2024a or EarlierUpdated Code in R2024b
fvtool(sos)
filterAnalyzer(sos(:,1:3),sos(:,4:6))

or

[ctfNum,ctfDen] = sos2ctf(sos);
filterAnalyzer(ctfNum,ctfDen)
hfvt = fvtool(sos);
set(hfvt.SOSViewSettings,View="cumulative")
[ctfNum,ctfDen] = sos2ctf(sos);
fa = filterAnalyzer(ctfNum,ctfDen,CTFAnalysisMode="cumulative");
hfvt = fvtool(sos);
set(hfvt.SOSViewSettings,View="userdefined",UserDefined={3,1})
[ctfNum,ctfDen] = sos2ctf(sos);
fa = filterAnalyzer(ctfNum,ctfDen, ...
    CTFAnalysisMode="specify",CTFAnalysisSections={3,1});