0% found this document useful (0 votes)
37 views32 pages

DSP System Toolbox Getting Started Guide

The DSP System Toolbox Getting Started Guide provides an overview of the toolbox's features for designing and simulating signal processing systems in MATLAB and Simulink. It includes instructions for configuring the Simulink environment, designing filters, and utilizing various model templates for efficient signal processing. The guide also emphasizes the toolbox's capabilities for real-time DSP applications across multiple domains, including communications and medical devices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views32 pages

DSP System Toolbox Getting Started Guide

The DSP System Toolbox Getting Started Guide provides an overview of the toolbox's features for designing and simulating signal processing systems in MATLAB and Simulink. It includes instructions for configuring the Simulink environment, designing filters, and utilizing various model templates for efficient signal processing. The guide also emphasizes the toolbox's capabilities for real-time DSP applications across multiple domains, including communications and medical devices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

DSP System Toolbox™

Getting Started Guide

R2024b
How to Contact MathWorks

Latest news: www.mathworks.com

Sales and services: www.mathworks.com/sales_and_services

User community: www.mathworks.com/matlabcentral

Technical support: www.mathworks.com/support/contact_us

Phone: 508-647-7000

The MathWorks, Inc.


1 Apple Hill Drive
Natick, MA 01760-2098
DSP System Toolbox™ Getting Started Guide
© COPYRIGHT 2011–2024 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied
only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form
without prior written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through
the federal government of the United States. By accepting delivery of the Program or Documentation, the government
hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer
software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014.
Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain
to and govern the use, modification, reproduction, release, performance, display, and disclosure of the Program and
Documentation by the federal government (or other entity acquiring for or through the federal government) and shall
supersede any conflicting contractual terms or conditions. If this License fails to meet the government's needs or is
inconsistent in any respect with federal procurement law, the government agrees to return the Program and
Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be
trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for
more information.
Revision History
April 2011 First printing Revised for Version 8.0 (R2011a)
September 2011 Online only Revised for Version 8.1 (R2011b)
March 2012 Online only Revised for Version 8.2 (R2012a)
September 2012 Online only Revised for Version 8.3 (R2012b)
March 2013 Online only Revised for Version 8.4 (R2013a)
September 2013 Online only Revised for Version 8.5 (R2013b)
March 2014 Online only Revised for Version 8.6 (R2014a)
October 2014 Online only Revised for Version 8.7 (R2014b)
March 2015 Online only Revised for Version 9.0 (R2015a)
September 2015 Online only Revised for Version 9.1 (R2015b)
March 2016 Online only Revised for Version 9.2 (R2016a)
September 2016 Online only Revised for Version 9.3 (R2016b)
March 2017 Online only Revised for Version 9.4 (R2017a)
September 2017 Online only Revised for Version 9.5 (R2017b)
March 2018 Online only Revised for Version 9.6 (R2018a)
September 2018 Online only Revised for Version 9.7 (R2018b)
March 2019 Online only Revised for Version 9.8 (R2019a)
September 2019 Online only Revised for Version 9.9 (R2019b)
March 2020 Online only Revised for Version 9.10 (R2020a)
September 2020 Online only Revised for Version 9.11 (R2020b)
March 2021 Online only Revised for Version 9.12 (R2021a)
September 2021 Online only Revised for Version 9.13 (R2021b)
March 2022 Online only Revised for Version 9.14 (R2022a)
September 2022 Online only Revised for Version 9.15 (R2022b)
March 2023 Online only Revised for Version 9.16 (R2023a)
September 2023 Online only Revised for Version 23.2 (R2023b)
March 2024 Online only Revised for Version 24.1 (R2024a)
September 2024 Online only Revised for Version 24.2 (R2024b)
Contents

Introduction
1
DSP System Toolbox Product Description . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

Configure Simulink Environment for Signal Processing Models . . . . . . . . 1-3


About DSP Simulink Model Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Create Model Using DSP System Toolbox Simulink Model Template . . . . . 1-3
DSP Simulink Model Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
See Also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9

Design Filters in Simulink


2
Design and Implement a Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Design a Digital Filter in Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
Add a Digital Filter to Your Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4

Remove Low Frequency Noise in Simulink Using Normalized LMS


Adaptive Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Design an Adaptive Filter in Simulink . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7
Add an Adaptive Filter to Your Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8
View the Coefficients of Your Adaptive Filter . . . . . . . . . . . . . . . . . . . . . . 2-11
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-15

v
1

Introduction

• “DSP System Toolbox Product Description” on page 1-2


• “Configure Simulink Environment for Signal Processing Models” on page 1-3
1 Introduction

DSP System Toolbox Product Description


Design and simulate streaming signal processing systems

DSP System Toolbox provides algorithms, apps, and scopes for designing, simulating, and analyzing
signal processing systems in MATLAB® and Simulink®. You can model real-time DSP systems for
communications, radar, audio, medical devices, IoT, and other applications.

With DSP System Toolbox you can design and analyze FIR, IIR, multirate, multistage, and adaptive
filters. You can stream signals from variables, data files, and network devices for system development
and verification. The Time Scope, Spectrum Analyzer, and Logic Analyzer let you dynamically
visualize and measure streaming signals. For desktop prototyping and deployment to embedded
processors, including ARM® Cortex® architectures, the toolbox supports C/C++ code generation. It
also supports bit-accurate fixed-point modeling and HDL code generation from filters, FFT, IFFT, and
other algorithms.

Algorithms are available as MATLAB functions, System objects, and Simulink blocks.

Key Features
• Signal processing and linear algebra blocks for Simulink
• Streaming signal processing in MATLAB
• Single-rate, multirate, FIR, IIR, and adaptive filter design
• Time Scope, Spectrum Analyzer, and Logic Analyzer for visualizing and measuring streaming
signals
• Fixed-point modeling and simulation of signal processing algorithms
• Support for C and C++ code generation
• Support for HDL code generation

1-2
Configure Simulink Environment for Signal Processing Models

Configure Simulink Environment for Signal Processing Models


In this section...
“About DSP Simulink Model Templates” on page 1-3
“Create Model Using DSP System Toolbox Simulink Model Template” on page 1-3
“DSP Simulink Model Templates” on page 1-4
“See Also” on page 1-9

About DSP Simulink Model Templates


DSP Simulink model templates let you automatically configure Simulink environment with
recommended settings for digital signal processing modeling. DSP Simulink model templates let you
reuse settings, including configuration parameters. You can create models from templates that use
best practices and take advantage of previous solutions to common problems. Instead of the default
canvas of a new model, select a template model to help you get started.

For more information on Simulink model templates, see “Create Template from Model” (Simulink).

Create Model Using DSP System Toolbox Simulink Model Template


To create a new blank model and open the library browser:

1 On the MATLAB Home tab, in the File section, click New > Simulink Model. The Simulink
Start Page opens with built-in Simulink model templates.

2 Click one of the templates under DSP System Toolbox to create a model with settings suitable
for use with DSP System Toolbox. A new model using the template settings and contents appears
in the Simulink Editor. The model is only in memory until you save it.

1-3
1 Introduction

3 To access the library browser, click Library Browser on the model toolstrip.

DSP Simulink Model Templates


When you create a model by choosing one of the DSP Simulink model templates, the model is
configured to use the settings recommended for DSP System Toolbox. This table shows some of these
settings.

Configuration Parameter Setting


SingleTaskRateTransMsg error
multiTaskRateTransMsg error
Solver fixedstepdiscrete
EnableMultiTasking Off
StartTime 0.0
StopTime inf
FixedStep auto
SaveTime off
SaveOutput off
AlgebraicLoopMsg error
SignalLogging off
FrameProcessingCompatibilityMsg error

These are the Simulink model templates in DSP System Toolbox:

• “Basic Filter” on page 1-4


• “Tunable FIR and IIR Filters” on page 1-5
• “Interpolated FIR Filter” on page 1-6
• “Mixed-Signal System” on page 1-7

Basic Filter

Click on Basic Filter to create a basic filtering model configured with settings recommended for DSP
System Toolbox.

This model implements a lowpass filter and enables you to compare the filtered signal with the
original signal. The model acts as a starting point for modeling filtering algorithms in Simulink using
DSP System Toolbox.

1-4
Configure Simulink Environment for Signal Processing Models

Here is the Spectrum Analyzer output showing the original signal and the filtered signal. The input
signal contains tones at 1 kHz and 15 kHz. The 1 kHz tone gets passed in the filtered output while the
15 kHz tone gets attenuated.

Tunable FIR and IIR Filters

Design and implement FIR and IIR filters with tunable filter specifications using the Tunable FIR
and IIR Filters template.

This model shows how to design FIR and IIR filters using the Lowpass FIR Filter Design and the
Lowpass IIR Filter Design design blocks. You can tune the filter cutoff frequency using the Knob

1-5
1 Introduction

block. The magnitude response of the designed filters varies as you tune the filter cutoff frequency
during simulation. Visualize the magnitude response of the designed filters using the Filter Visualizer
block. As with the Basic Filter model template, the input is a noisy sinusoidal signal with tones at 1
kHz and 15 kHz.

The Discrete FIR Filter block and the Second-Order Section Filter block implement a lowpass FIR
filter and a highpass IIR filter using the coefficients from the design blocks.

The Filter Visualizer output shows the varying magnitude response of the FIR filter and the IIR filter,
and the Spectrum Analyzer output shows the spectra of the original and the filtered signals. In the
Spectrum Analyzer output, both tones get attenuated. The 1 kHz tone gets attenuated by the IIR filter
and the 15 kHz tone gets attenuated by the FIR filter.

Interpolated FIR Filter

The Interpolated FIR Filter template provides an efficient alternative to a single-stage high-order
FIR filter, as it filters the signal at a lower sampling rate. This implementation processes the input
signal in multiple stages. A noisy input first passes through an FIR decimator, which lowers the
sampling rate of the signal. The signal is then filtered by an FIR filter at this lower sampling rate. An
FIR interpolator at the end converts the sampling rate of the filtered output back to its original value.

1-6
Configure Simulink Environment for Signal Processing Models

The Spectrum Analyzer block in the model shows the spectrum of the filtered signal.

Mixed-Signal System

Click the Mixed-Signal System template to create a basic A/D converter model configured with
settings recommended for DSP System Toolbox and mixed-signal systems. This model performs A/D
conversion by implementing an analog anti aliasing filter followed by a zero-order hold circuit. The
model acts as a starting point for modeling mixed-signal systems in Simulink using DSP System
Toolbox. All discrete-time signals are colored in red to indicate the fastest sample rate. Continuous-
time signals are colored in black. For additional sample time options, in the Debug tab, select
Information Overlays > Colors.

1-7
1 Introduction

The Scope block in the model plots the continuous-time signal and the discrete-time signal.

The Spectrum Analyzer block shows the spectrum of the discrete-time signal.

1-8
Configure Simulink Environment for Signal Processing Models

See Also
• “Filter Frames of a Noisy Sine Wave Signal in Simulink”

1-9
2

Design Filters in Simulink

• “Design and Implement a Filter” on page 2-2


• “Remove Low Frequency Noise in Simulink Using Normalized LMS Adaptive Filter” on page 2-7
2 Design Filters in Simulink

Design and Implement a Filter


In this section...
“Design a Digital Filter in Simulink” on page 2-2
“Add a Digital Filter to Your Model” on page 2-4

Design a digital lowpass filter using the Digital Filter Design block and incorporate the block into
your model to simulate the presence of low frequency noise.

You can design lowpass, highpass, bandpass, and bandstop filters using either the Digital Filter
Design block or the Filter Realization Wizard. These blocks are capable of calculating filter
coefficients for various filter structures. This topic uses the Digital Filter Design block to convert
white noise to low frequency noise so you can simulate its effect on your system.

As a practical application, suppose a pilot is speaking into a microphone within the cockpit of an
airplane. The noise of the wind passing over the fuselage is also reaching the microphone. A sensor is
measuring the noise of the wind on the outside of the plane. You want to estimate the wind noise
inside the cockpit and subtract it from the input to the microphone so that only the pilot's voice is
transmitted.

In the first section of this topic, you learn how to model the low frequency noise that is reaching the
microphone. In the second section of the topic, you learn how to remove this noise so that only the
pilot's voice is heard.

Design a Digital Filter in Simulink

In this section, you use a Digital Filter Design block to create low frequency noise, which models the
wind noise inside the cockpit.

Open the ex_gstut3 model. This model contains a Scope block that displays the original sine wave
and the sine wave with white noise added.

Open the DSP System Toolbox™ library by typing dsplib at the MATLAB® command prompt.

Convert white noise to low frequency noise by introducing a Digital Filter Design block into your
model. In the airplane scenario, the air passing over the fuselage creates white noise that is
measured by a sensor. The Random Source block models this noise. The fuselage of the airplane
converts this white noise to low frequency noise, a type of colored noise, which is heard inside the

2-2
Design and Implement a Filter

cockpit. This noise contains only certain frequencies and is more difficult to eliminate. In this
example, you model the low frequency noise using a Digital Filter Design block. This block uses the
functionality of the Filter Design and Analysis Tool (FDATool) to design a filter.

Double-click the Filtering library, and then double-click the Filter Implementations sublibrary. Click-
and-drag the Digital Filter Design block into your model.

Set the Digital Filter Design block parameters to design a lowpass filter and create low frequency
noise. Open the block parameters dialog box by double-clicking the block. Set the parameters as
follows:

• Response Type = Lowpass


• Design Method = FIR. From the list, choose Window.
• Filter Order = Specify order and enter 31.
• Scale Passband is cleared.
• Window = Hamming
• Units = Normalized (0 to 1)
• wc = 0.5

Based on these parameters, the Digital Filter Design block designs a lowpass FIR filter with 32
coefficients and a cutoff frequency of 0.5. The block multiplies the time-domain response of your filter
by a 32 sample Hamming window.

Click Design Filter at the bottom center of the dialog box to view the magnitude response of your
filter in the Magnitude Response pane. The Digital Filter Design dialog box should now look similar
to the following figure.

2-3
2 Design Filters in Simulink

You have now designed a digital lowpass filter using the Digital Filter Design block.

You can experiment with the Digital Filter Design block in order to design a filter of your own. For
more information on the block functionality, see the Digital Filter Design block reference page.

Add a Digital Filter to Your Model

In this section, you add the lowpass filter you designed in “Design a Digital Filter in Simulink” on
page 2-2 to your block diagram. Use this filter, which converts white noise to colored noise, to
simulate the low frequency wind noise inside the cockpit:

If the model you created in “Design a Digital Filter in Simulink” on page 2-2 is not open on your
desktop, open ex_gstut4 which is an equivalent model.

2-4
Design and Implement a Filter

Incorporate the Digital Filter Design block into your block diagram by placing it between the Random
Source block and the Sum block.

Run your model and view the results in the Scope window. This window shows the original input
signal and the signal with low frequency noise added to it.

2-5
2 Design Filters in Simulink

You have now built a digital filter and used it to model the presence of colored noise in your signal.
This is analogous to modeling the low frequency noise reaching the microphone in the cockpit of the
aircraft. Now that you have added noise to your system, you can experiment with methods to
eliminate it.

See Also
Blocks
Digital Filter Design | Filter Realization Wizard

Related Examples
• “Remove Low Frequency Noise in Simulink Using Normalized LMS Adaptive Filter” on page 2-
7
• “Using Filter Designer”

2-6
Remove Low Frequency Noise in Simulink Using Normalized LMS Adaptive Filter

Remove Low Frequency Noise in Simulink Using Normalized


LMS Adaptive Filter
In this section...
“Design an Adaptive Filter in Simulink” on page 2-7
“Add an Adaptive Filter to Your Model” on page 2-8
“View the Coefficients of Your Adaptive Filter” on page 2-11
“Summary” on page 2-15

Adaptive filters track the dynamic nature of a system and allow you to eliminate time-varying signals.
The DSP System Toolbox libraries contain blocks that implement least-mean-square (LMS), block
LMS, fast block LMS, and recursive least squares (RLS) adaptive filter algorithms. These filters
minimize the difference between the output signal and the desired signal by altering their filter
coefficients. Over time, the adaptive filter's output signal more closely approximates the signal you
want to reproduce.

Design an Adaptive Filter in Simulink

In this example, you design an LMS adaptive filter to remove the low frequency noise in your signal:

If the model you created in “Add a Digital Filter to Your Model” on page 2-4 is not open on your
desktop, open ex_gstut5 which is an equivalent model.

Open the DSP System Toolbox™ library by typing dsplib at the MATLAB® command prompt.

Remove the low frequency noise from your signal by adding an LMS Filter block to your system. In
the airplane scenario, this is equivalent to subtracting the wind noise inside the cockpit from the
input to the microphone. Double-click the Filtering library, and then double-click the Adaptive Filters
library. Add the LMS Filter block into your model.

2-7
2 Design Filters in Simulink

Set the LMS Filter block parameters to model the output of the Digital Filter Design block. Open the
LMS Filter dialog box by double-clicking the block. Set and apply the block parameters as follows:

• Algorithm = Normalized LMS


• Filter length = 32
• Specify step size via = Dialog
• Step size (mu) = 0.1
• Leakage factor (0 to 1) = 1.0
• Initial value of filter weights = 0
• Clear the Adapt port check box.
• Reset port = None
• Select the Output filter weights check box.

Based on these parameters, the LMS Filter block computes the filter weights using the normalized
LMS equations. The filter order you specified is the same as the filter order of the Digital Filter
Design block. The Step size (mu) parameter defines the granularity of the filter update steps.
Because you set the Leakage factor (0 to 1) parameter to 1.0, the current filter coefficient values
depend on the filter's initial conditions and all of the previous input values. The initial value of the
filter weights (coefficients) is zero. Since you selected the Output filter weights check box, the Wts
port appears on the block. The block outputs the filter weights from this port.

Now that you have set the block parameters of the LMS Filter block, you can incorporate this block
into your block diagram.

Add an Adaptive Filter to Your Model

In this example, you recover your original sinusoidal signal by incorporating the adaptive filter you
designed in “Design an Adaptive Filter in Simulink” on page 2-7 into your system. In the aircraft
scenario, the adaptive filter models the low frequency noise heard inside the cockpit. As a result, you
can remove the noise so that the pilot's voice is the only input to the microphone:

If the model you created in “Design an Adaptive Filter in Simulink” on page 2-7 is not open on your
desktop, open ex_gstut6 which is an equivalent model.

2-8
Remove Low Frequency Noise in Simulink Using Normalized LMS Adaptive Filter

Add a Sum block to your model to subtract the output of the adaptive filter from the sinusoidal signal
with low frequency noise. From the Simulink® Math Operations library, drag a Sum block into your
model. Open the Sum dialog box by double-clicking this block. Change the List of signs parameter
to |+- and then click OK.

Incorporate the LMS Filter block into your system.

• Connect the output of the Random Source block to the Input port of the LMS Filter block. In the
aircraft scenario, the random noise is the white noise measured by the sensor on the outside of
the airplane. The LMS Filter block models the effect of the airplane's fuselage on the noise.
• Connect the output of the Digital Filter Design block to the Desired port on the LMS Filter block.
This is the signal you want the LMS block to reproduce.
• Connect the output of the LMS Filter block to the negative port of the Sum block you added in
step 2.
• Connect the output of the first Sum block to the positive port of the second Sum block. Your model
should now look similar to the following figure.

2-9
2 Design Filters in Simulink

The positive input to the second Sum block is the sum of the input signal and the low frequency noise,
s(n) + y. The negative input to the second Sum block is the LMS Filter block's best estimation of the
low frequency noise, y'. When you subtract the two signals, you are left with an approximation of the
input signal.

sn approx = s n + y − y′

In this equation:

• s n is the input signal.


• sn approx is the approximation of the input signal.
• y is the noise created by the Random Source block and the Digital Filter Design block.
• y′ is the LMS Filter block's approximation of the noise.

Because the LMS Filter block can only approximate the noise, there is still a difference between the
input signal and the approximation of the input signal. In subsequent steps, you set up the Scope
block so you can compare the original sinusoidal signal with its approximation.

Add two additional inputs and axes to the Scope block. Open the Scope dialog box by double-clicking
the Scope block. Click the Parameters button. For the Number of input ports parameter, enter 4.
Close the dialog box by clicking OK.

Label the new Scope axes. In the Scope window, right-click on the third axes and select Axes
properties. The Scope properties: axis 3 dialog box opens. In the Title box, enter Approximation
of Input Signal. Close the dialog box by clicking OK. Repeat this procedure for the fourth axes
and label it Error.

Connect the output of the second Sum block to the third port of the Scope block.

2-10
Remove Low Frequency Noise in Simulink Using Normalized LMS Adaptive Filter

Connect the output of the Error port on the LMS Filter block to the fourth port of the Scope block.
Your model should now look similar to the following figure.

In this example, the output of the Error port is the difference between the LMS filter's desired signal
and its output signal. Because the error is never zero, the filter continues to modify the filter
coefficients in order to better approximate the low frequency noise. The better the approximation, the
more low frequency noise that can be removed from the sinusoidal signal. In the next topic, “View the
Coefficients of Your Adaptive Filter” on page 2-11, you learn how to view the coefficients of your
adaptive filter as they change with time.

View the Coefficients of Your Adaptive Filter

The coefficients of an adaptive filter change with time in accordance with a chosen algorithm. Once
the algorithm optimizes the filter's performance, these filter coefficients reach their steady-state
values. You can view the variation of your coefficients, while the simulation is running, to see them
settle to their steady-state values. Then, you can determine whether you can implement these values
in your actual system:

If the model you created in Add an “Add an Adaptive Filter to Your Model” on page 2-8 is not open on
your desktop, open ex_gstut7 which is an equivalent model.

Note that the Wts port of the adaptive filter, which outputs the filter weights, still needs to be
connected.

2-11
2 Design Filters in Simulink

Open the DSP System Toolbox™ library by typing dsplib at the MATLAB® command prompt.

View the filter coefficients by connecting a Time Scope block to the Wts port of the LMS Filter block.

On the Time Scope block, modify the following configuration properties:

• Time span = 0.05


• Y-limits (Minimum) = -0.15
• Y-limits (Maximum) = 0.5

2-12
Remove Low Frequency Noise in Simulink Using Normalized LMS Adaptive Filter

Open Model Settings. In the Modeling tab, click Model Settings. In the Solver pane, set these
configuration parameters:

• Stop time = inf


• Type = Fixed-step
• Solver = discrete (no continuous states)

We recommend these configuration parameters for models that contain DSP System Toolbox blocks.
Because these blocks calculate values directly rather than solving differential equations, you must
configure the Simulink® Solver to behave like a scheduler. The Solver, while in scheduler mode, uses
a block's sample time to determine when the code behind each block is executed. For example, the
sample time of the Sine Wave and Random Source blocks in this model is 0.05. The Solver executes
the code behind these blocks, and every other block with this sample time, once every 0.05 second.

Note: When working with models that contain DSP System Toolbox blocks, use source blocks that
enable you to specify their sample time. If your source block does not have a Sample time
parameter, you must add a Zero-Order Hold block in your model and use it to specify the sample time.
For more information, see “Continuous-Time Source Blocks”. The exception to this rule is the
Constant block, which can have a constant sample time. When it does, Simulink executes this block
and records the constant value once at the start of the simulation and any time you tune a parameter.
This allows for faster simulations and more compact generated code.

Run your model and view the behavior of your filter coefficients in the Time Scope, which opens
automatically when your simulation starts. Over time, the filter coefficients approach their steady-
state values.

2-13
2 Design Filters in Simulink

You can also view the behavior of the system in the Scope window. Over time, you see the error
decrease and the approximation of the input signal more closely match the original sinusoidal input
signal.

2-14
Remove Low Frequency Noise in Simulink Using Normalized LMS Adaptive Filter

You have now created a model capable of adaptive noise cancellation.

Summary
You have learned how to design a lowpass filter using the Digital Filter Design block. You also learned
how to create an adaptive filter using the LMS Filter block. The DSP System Toolbox product has
other blocks capable of designing and implementing digital and adaptive filters. For more information
on the filtering capabilities of this product, see “Filter Design” and “Filter Analysis”.

Because all blocks in this model have the same sample time, this model is single rate, and Simulink
ran it in SingleTasking solver mode. If the blocks in your model have different sample times, your
model is multirate and Simulink might run it in MultiTasking solver mode. For more information on
solver modes, see “Recommended Settings for Discrete-Time Simulations”.

To learn how to generate code from your model using the Simulink Coder™ product, see “Generate C
Code from Simulink Model”.

See Also
LMS Filter | Digital Filter Design

More About
• “Filter Design”
• “Filter Analysis”

2-15

You might also like