visualize
Visualize frequency response of individual filter stages or sum of filter paths between input and output channels
Since R2024b
Description
visualize(
visualizes the frequency
response of the individual filters of the input filter object.filtObj
)
visualize(___,
visualizes the frequency response of the filter with additional properties specified by one
or more name-value arguments.Name=Value
)
For example, to visualize the frequency response of the sum of all filter paths between
each input and output channel, set SumFilterPaths
to
true
.
Example: visualize(filtobj,SumFilterPaths=true,NumInputChannels=2)
returns the
handle to the DFV
= visualize(___)dsp.DynamicFilterVisualizer
object which contains the settings to customize the
filter visualization.
Examples
Visualize Frequency Response of Filters
Use the visualize
function to visualize the frequency response of the individual filters in a SIMO system and the sum of the filters between each input channel and output channel pair. The SIMO system models one input channel, two output channels, and two paths between each input channel and output channel pair.
Design four lowpass FIR filters with varying cutoff frequencies. The filter order for each filter is 400.
order = 4000; num = [ % Path 1, Output Channel 1 designLowpassFIR(FilterOrder=order,CutoffFrequency=0.2);... % Path 2, Output Channel 1 designLowpassFIR(FilterOrder=order,CutoffFrequency=0.3);... % Path 1, Output Channel 2 designLowpassFIR(FilterOrder=order,CutoffFrequency=0.4);... % Path 2, Output Channel 2 designLowpassFIR(FilterOrder=order,CutoffFrequency=0.5)];
Initialize the dsp.MIMOFIRFilter
with the array of filters.
simoFilt = dsp.MIMOFIRFilter(num,NumPaths=2)
simoFilt = dsp.MIMOFIRFilter with properties: NumeratorSource: 'Property' Numerator: [4x4001 double] NumPaths: 2 SumFilteredOutputs: true
Visualize the frequency response of the four individual filters. Update the title of the filter visualizer using the Title
property of the visualization handle.
vizHandle = visualize(simoFilt)
vizHandle = dsp.DynamicFilterVisualizer handle with properties: FFTLength: 8192 NormalizedFrequency: 1 FrequencyRange: [0 1] XScale: 'Linear' MagnitudeDisplay: 'Magnitude (dB)' PlotAsMagnitudePhase: 0 PlotType: 'Line' AxesScaling: 'Auto' Show all properties
vizHandle.Title = "Magnitude Response of Individual Filters";
Visualize the frequency response of the sum of all the filters between each input channel and output channel by setting the SumFilterPaths
to true
.
To use the SumFilterPaths
property, you must pass input data to the MIMO FIR filter object or set the NumInputChannels
property of the visualize
function to a positive integer. In this case, set NumInputChannels
to 1.
vizHandle = visualize(simoFilt,NumInputChannels=1,SumFilterPaths=true);
Update the filter visualizer title accordingly.
vizHandle.Title = "Magnitude Response of Sum of Filter Paths";
Filter Input Signal Using 1-by-2 SIMO System
Design four bandpass FIR filters, each with a different center frequency, specified in normalized frequency units. The bandwidth for each filter is 0.1. The SIMO system models one input channel, two output channels, and two paths between each input channel and output channel pair.
bw = 0.1; num = [ % Path 1, Output Channel 1 designBandpassFIR(CenterFrequency=0.5,bandwidth=bw);... % Path 2, Output Channel 1 designBandpassFIR(CenterFrequency=0.6,bandwidth=bw);... % Path 1, Output Channel 2 designBandpassFIR(CenterFrequency=0.7,bandwidth=bw);... % Path 2, Output Channel 2 designBandpassFIR(CenterFrequency=0.8,bandwidth=bw)];
Initialize the dsp.MIMOFIRFilter
object with the array of filters. Set the number of filter paths to 2.
simoFilt = dsp.MIMOFIRFilter(num,NumPaths=2)
simoFilt = dsp.MIMOFIRFilter with properties: NumeratorSource: 'Property' Numerator: [4x101 double] NumPaths: 2 SumFilteredOutputs: true
Visualize the frequency response of the individual filter stages using the visualize
function.
visualize(simoFilt)
The input contains two sinusoidal signals, each with a frame length of 256. The first sinusoidal signal has a frequency of 2100 Hz and the second sinusoidal signal has a frequency of 3000 Hz.
Fs = 8000; frameLen = 256; sin_2100Hz = dsp.SineWave(Frequency=2100,SampleRate=Fs,... SamplesPerFrame=frameLen); sin_3kHz = dsp.SineWave(Frequency=3e3,SampleRate=Fs,... SamplesPerFrame=frameLen);
Initialize a spectrumAnalyzer
object to view the spectrum of the input and the filtered output.
specScope = spectrumAnalyzer(SampleRate=Fs,PlotAsTwoSidedSpectrum=false,... ChannelNames={'Input','Output Channel 1',... 'Output Channel 2'},ShowLegend=true);
Stream in 1e4 frames of the noisy input sinusoidal signal. The input noise is white Gaussian with a mean of 0 and a variance of 0.01. Since there are four filters, one input channel, and two paths between each input channel and output channel, the number of output channels of the system is given by . Pass the signal through the designed filter. Visualize the spectrum of the input and output signals in the spectrum analyzer.
for idx = 1:1e4 x = sin_2100Hz() + sin_3kHz() + 0.01 * randn(frameLen, 1); y = simoFilt(x); specScope([x, y]); end
Visualize the frequency response of sum of all the filter paths between each input channel and output channel by setting SumFilterPaths
to true
.
visualize(simoFilt,SumFilterPaths=true)
Input Arguments
filtObj
— Input filter
dsp.FrequencyDomainFIRFilter
| dsp.MIMOFIRFilter
dsp.FrequencyDomainFIRFilter
dsp.MIMOFIRFilter
Input filter, specified as one of these filter objects:
NFFT
— Number of FFT bins
8192
(default) | positive integer
Number of FFT bins the function uses to calculate the frequency response, specified as a positive integer.
Data Types: single
| double
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.
Example: vizHandle =
visualize(filtObj,SumFilterPaths=true,NumInputChannels=2)
SumFilterPaths
— Visualize sum of frequency response of all filter paths between input and output channel
false
(default) | true
Visualize the sum of the frequency response of all filter paths between a given input and output channel, specified as one these:
true
–– The function visualizes the sum of the frequency response of all filter paths between a given input and output channel.false
–– The function visualizes the frequency response of the individual filter stages.
Data Types: logical
NumInputChannels
— Number of input channels
positive integer
Number of input channels, specified as a positive integer. When you set
SumFilterPaths
to true
and do not specify
any input data to the input filter object, the visualize
function
uses the value in this property to determine the number of input channels in the
input.
Data Types: single
| double
Output Arguments
DFV
— Handle to dynamic filter visualizer object
dsp.DynamicFilterVisualizer
object
dsp.DynamicFilterVisualizer
Handle to the dynamic filter visualizer object, returned as a dsp.DynamicFilterVisualizer
object. Using this handle, you can customize the
display properties, measurements, and color and styling properties of the dynamic filter
visualizer.
Version History
Introduced in R2024b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)