# FVTool

(To be removed) Filter Visualization Tool

FVTool will be removed in a future release. Use Filter Analyzer instead. For more information, see Version History.

## Description

Filter Visualization Tool is an interactive app that enables you to display and analyze the responses, coefficients, and other information of a filter. You can also synchronize FVTool and Filter Designer to immediately visualize any changes made to a filter design.

In the app, you can view:

• Magnitude response

• Phase response

• Group delay

• Phase delay

• Impulse response

• Step response

• Pole-zero plot

• Filter coefficients

• Filter information

If you have installed the DSP System Toolbox™, FVTool can also visualize the frequency response of a filter System object™. If you need to filter streaming data in real time, using System objects is the recommended approach. For more information, see `fvtool` (DSP System Toolbox).

## Open the FVTool

FVTool can be opened programmatically using one of the methods described in Programmatic Use.

## Examples

expand all

Consider a 6th-order elliptic filter with a passband ripple of 3 dB, a stopband attenuation of 50 dB, a sample rate of 1 kHz, and a normalized passband edge of 300 Hz. Display the magnitude response of the filter.

```[b,a] = ellip(6,3,50,300/500); fvtool(b,a)```

## Programmatic Use

expand all

`fvtool(b,a)` opens FVTool and displays the magnitude response of the digital filter defined with numerator `b` and denominator `a`. Specify `b` and `a` coefficients in ascending order of power z-1.

`fvtool(sos)` opens FVTool and displays the magnitude response of the digital filter defined by the L-by-6 matrix of second order sections:

`$\text{sos}=\left[\begin{array}{cccccc}{b}_{01}& {b}_{11}& {b}_{21}& 1& {a}_{11}& {a}_{21}\\ {b}_{02}& {b}_{12}& {b}_{22}& 1& {a}_{12}& {a}_{22}\\ ⋮& ⋮& ⋮& ⋮& ⋮& ⋮\\ {b}_{0L}& {b}_{1L}& {b}_{2L}& 1& {a}_{1L}& {a}_{2L}\end{array}\right]$`

The rows of `sos` contain the numerator and denominator coefficients bik and aik of the cascade of second-order sections of H(z):

`$H\left(z\right)=g\prod _{k=1}^{L}{H}_{k}\left(z\right)=g\prod _{k=1}^{L}\frac{{b}_{0k}+{b}_{1k}{z}^{-1}+{b}_{2k}{z}^{-2}}{1+{a}_{1k}{z}^{-1}+{a}_{2k}{z}^{-2}}.$`

The number of sections L must be greater than or equal to 2. If the number of sections is less than 2, `fvtool` considers the input to be a numerator vector.

`fvtool(d)` opens FVTool and displays the magnitude response of a digital filter `d`. Use `designfilt` to generate `d` based on frequency-response specifications.

`fvtool(b1,a1,b2,a2,...,bN,aN)` opens FVTool and displays the magnitude responses of multiple filters defined with numerators `b1`, …, `bN` and denominators `a1`, ..., `aN`.

`fvtool(sos1,sos2,...,sosN)` opens FVTool and displays the magnitude responses of multiple filters defined with second order section matrices `sos1`, `sos2`, ..., `sosN`.

`fvtool(Hd)` opens FVTool and displays the magnitude responses for the `dfilt` filter object `Hd` or the array of `dfilt` filter objects.

`fvtool(Hd1,Hd2,...,HdN)` opens FVTool and displays the magnitude responses of the filters in the `dfilt` objects `Hd1`, `Hd2`, ..., `HdN`.

`h = fvtool(___)` returns a figure handle `h`. You can use this handle to interact with FVTool from the command line. For more information, see Controlling FVTool from the MATLAB Command Line.

expand all

## Version History

Introduced before R2006a

expand all

### R2024b: FVTool will be removed

FVTool will be removed in a future release. Use Filter Analyzer instead. There are differences that require updates to your code.

Consider these filters:

```[b,a] = ellip(5,5,60,[0.2 0.45]); dFd = designfilt("bandpassfir", ... SampleRate=2e3,PassbandRipple=5, ... StopbandFrequency1=500,PassbandFrequency1=600, ... StopbandAttenuation1=80, ... PassbandFrequency2=750,StopbandFrequency2=900, ... StopbandAttenuation2=40);```

Given the filter numerator coefficients `b`, denominator coefficients `a`, and the `digitalFilter` object `dFd`, you must make the following updates to your 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 Cascaded Transfer Functions 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});```