DSP Blockset ® For Use with Simulink Modeling Simulation Implementation User’s Guide Version 4
How to Contact The MathWorks: www.mathworks.com comp.soft-sys.matlab Web Newsgroup info@mathworks.com Technical support Product enhancement suggestions Bug reports Documentation error reports Order status, license renewals, passcodes Sales, pricing, and general information 508-647-7000 Phone 508-647-7001 Fax The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098 Mail support@mathworks.com suggest@mathworks.com bugs@mathworks.com doc@mathworks.com service@mathworks.
Contents Introduction 1 Welcome to the DSP Blockset . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2 What Is the DSP Blockset? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3 What Is in the DSP Blockset? . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Working with Signals 3 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Signal Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Discrete-Time Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Continuous-Time Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 Multichannel Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Displaying Signals in the Time-Domain . . . . . . . . . . . . . . . . . . 3-80 Displaying Signals in the Frequency-Domain . . . . . . . . . . . . . 3-82 Displaying Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-83 Delay and Latency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-85 Computational Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-85 Algorithmic Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Queues Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sigma-Delta A/D Conversion Demo . . . . . . . . . . . . . . . . . . . . . Sine Wave Generation Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . Spectral Analysis Demos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Statistical Functions Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wavelets Demos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Constant Diagonal Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-82 Constant Ramp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-84 Contiguous Copy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-86 Convert 1-D to 2-D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-88 Convert 2-D to 1-D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-90 Convert Complex DSP To Simulink . . . . . . . . .
From Wave File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Histogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IDCT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Identity Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IFFT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Inherit Complexity . . . . . . . . . . . . . . . . .
Polynomial Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Polynomial Stability Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . Pseudoinverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . QR Factorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . QR Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Variable Integer Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Variable Selector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Vector Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wavelet Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wavelet Synthesis . . . . . . . . . . . . . . . . . . . . . . . . . .
1 Introduction Welcome to the DSP Blockset . . . . . . . . . . . . 1-2 What Is the DSP Blockset? . . . . . . . . . . . . . 1-3 Key Features . . . . . . . . . . . . . . . . . . . . 1-3 What Is in the DSP Blockset? . . . . . . . . . . . . 1-6 Installation . . . . . . . . . . . . . . . . . . . . . 1-7 Getting Started with the DSP Blockset How to Get Help Online . . . . . . . . How to Use This Guide . . . . . . . . Technical Conventions . . . . . . . . Typographical Conventions . . . . . .
1 Introduction Welcome to the DSP Blockset Welcome to the DSP Blockset, the premier tool for digital signal processing (DSP) algorithm simulation and code generation.
What Is the DSP Blockset? What Is the DSP Blockset? The DSP Blockset is a collection of block libraries for use with the Simulink dynamic system simulation environment. The DSP Blockset libraries are designed specifically for digital signal processing (DSP) applications, and include key operations such as classical, multirate, and adaptive filtering, matrix manipulation and linear algebra, statistics, time-frequency transforms, and more.
1 Introduction into all of its blocks. A completely frame-based model can run several times faster than the same model processing sample-by-sample; faster still if data sources are frame based. See “Sample Rates and Frame Rates” on page 3-16 for more information. Matrix Support The DSP Blockset takes full advantage of Simulink’s matrix format.
What Is the DSP Blockset? The multirate filtering algorithms employ polyphase implementations for efficient simulation and real-time code execution. Statistical Operations Use the blocks in the Statistics library for basic statistical analysis. These blocks calculate measures of central tendency and spread (e.g., mean, standard deviation, and so on), as well as the frequency distribution of input values (histograms).
1 Introduction What Is in the DSP Blockset? The DSP Blockset contains a collection of blocks organized in a set of nested libraries. The best way to explore the blockset is to expand the DSP Blockset entry in the Simulink Library Browser. The fully expanded library list is shown below. See the Simulink documentation for complete information about the Library Browser. To access the blockset through its own window (rather than through the Library Browser), type dsplib in the command window.
What Is in the DSP Blockset? Double-click on a demo in the list to open that model, and select Start from the model window’s Simulation menu to run it. For a complete list of all the blocks in the DSP Blockset by library, see “Block Library Contents” on page 5-10. Installation The DSP Blockset follows the same installation procedure as the MATLAB toolboxes. See the MATLAB Installation Guide for your platform.
1 Introduction Getting Started with the DSP Blockset To get started with the DSP Blockset, open the Simulink Library Browser by pressing the button on the MATLAB toolbar, or by typing simulink at the command line. Expand the DSP Blockset library tree in the Simulink Library Browser by clicking the symbol next to the DSP Blockset entry. You can drag blocks directly from the Library Browser into a Simulink model.
Getting Started with the DSP Blockset • Help browser – Select Full Product Family Help from the Help menu, or type doc or helpdesk at the command line to display the Help browser. Select DSP Blockset in the Contents pane. • Command Line – Type doc('block name') at the command line to access the help for a block with the name block name. Spaces and capitalization in the block name are ignored. • Help Desk (remote) – Use a Web browser or the Help browser to connect to the MathWorks Web site at www.mathworks.
1 Introduction Technical Conventions The following sections provides a brief overview of the technical conventions used in this guide, and provides pointers to more detailed information: • “Signal Dimension Nomenclature” • “Frame-Based Signal Nomenclature” • “Sampling Nomenclature” Signal Dimension Nomenclature The DSP Blockset fully supports Simulink’s matrix format, which is described in “Working with Signals” in the Simulink documentation.
Getting Started with the DSP Blockset • One-dimensional array, also called a 1-D vector • 1-by-N matrix, also called a row vector • M-by-1 matrix, also called a column vector The size or length of a vector, M for a column vector or N for a row vector, is the number of elements that it contains. There is no MATLAB equivalent for a 1-D Simulink vector (i.e., all MATLAB vectors have either a row or column orientation), and most blocks in the DSP Blockset treat a 1-D vector as a column vector. Arrays.
1 Introduction Typographical Conventions This manual uses some or all of these conventions. Item Convention to Use Example Example code Monospace font To assign the value 5 to A, enter A = 5 Function names/syntax Monospace font The cos function finds the cosine of each array element. Syntax line example is MLGetVar ML_var_name Keys Literal strings (in syntax descriptions in Reference chapters) Mathematical expressions MATLAB output Boldface with an initial capital letter Press the Return key.
R12 Related Products R12 Related Products The MathWorks provides several products that are especially relevant to the kinds of tasks you can perform with the DSP Blockset. For more information about any of these products, see either: • The online documentation for that product if it is installed or if you are reading the documentation from the CD • The MathWorks Web site, at http://www.mathworks.
1 Introduction 1-14 Product Description Motorola DSP Developer’s Kit Developer's kit for co-simulating and verifying Motorola 56300 and 56600 fixed-point DSP code.
2 Simulink and the DSP Blockset Overview . . . . . . . . . . . . . . . . . . . . . 2-2 The Simulink Environment Starting Simulink . . . . . Getting Started with Simulink Learning More About Simulink . . . . . . . . . . . . . . . . . . . . Configuring Simulink for DSP Systems Using dspstartup.m . . . . . . . . . Customizing dspstartup.m . . . . . . . Performance-Related Settings . . . . . Miscellaneous Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2 Simulink and the DSP Blockset Overview This chapter will help you get started building DSP models with Simulink and the DSP Blockset. It contains the following sections: • “The Simulink Environment” • “Configuring Simulink for DSP Systems” The first section provides a brief overview of the Simulink environment. The second section provides guidance in tailoring the environment for DSP system simulation.
The Simulink Environment The Simulink Environment Simulink is an environment for simulating dynamic systems. It provides a modeling and simulation “foundation” on which you can build digital signal processing applications. All of the blocks in the DSP Blockset are designed for use together with the blocks in the Simulink libraries.
2 Simulink and the DSP Blockset The first item in the list is the Simulink blockset itself, which is already expanded to show the available Simulink libraries. Click the symbol to the left of any blockset name to expand the hierarchical list and display that blockset’s libraries within the browser. See the Simulink documentation for a complete description of the Library Browser. Simulink on UNIX Platforms On UNIX platforms, the Simulink window below opens when you start Simulink.
The Simulink Environment The following tutorial makes use of the Simulink Library Browser, available only on PC platforms. If you are working on a UNIX platform, instead of clicking the symbol in the Library Browser to open a library, simply double-click the appropriate library in the main Simulink or DSP Blockset windows. To open the DSP Blockset window from the MATLAB command line, type dsplib.
2 Simulink and the DSP Blockset 1 Type dspstartup at the MATLAB command line to configure Simulink for DSP simulation (optional). One of the things that dspstartup does is set the Stop time value in the Simulation parameters dialog box to inf for all new models. The inf setting instructs Simulink to run the model until you click the simulation stop button. You can access this dialog box and enter a different Stop time value by selecting Simulation parameters from the model window’s Simulation menu.
The Simulink Environment 6 Add a Scope block to the model. a Click Sinks (in the Simulink tree) to view the blocks in the Simulink Sinks library. b Drag the Scope block from the Sinks library into the model window. (The Simulink Scope block is the same as the Time Scope block in the DSP Sinks library.) 7 Connect the blocks. a Position the pointer near the output port of the Sine Wave block.
2 Simulink and the DSP Blockset Close the dialog box by clicking on the OK button or by pressing Enter on the keyboard. b Double-click on the Matrix Sum block. Select Rows from the Sum along parameter, and close the dialog box. You can now move on to the model simulation phase. Model Simulation Simulink is also a model simulation environment. You can run the simulation block diagram that you have built to see how the system behaves. To do this: 1 Select Signal dimensions from the Format menu (optional).
The Simulink Environment to produce a scalar output. Thus, the input to the Scope block is the point-by-point sum of the two sinusoids. 2 Double-click on the Scope block if the Scope window is not already open on your screen. The scope window appears. 3 Select Start from the Simulation menu in the block diagram window. The signal containing the summed 10 Hz and 20 Hz component sinusoids is plotted on the scope. 4 Adjust the Scope block’s display.
2 Simulink and the DSP Blockset Running a Simulation from an M-File. You can also modify and run a Simulink simulation from within a MATLAB M-file. By doing this, you can automate the variation of model parameters to explore a large number of simulation conditions rapidly and efficiently. For information on how to do this, see “Delay and Latency” on page 3-85 and “Running a Simulation from the Command Line” in the Simulink documentation.
Configuring Simulink for DSP Systems Configuring Simulink for DSP Systems When you create a new DSP model, you may want to adjust certain Simulink settings to suit your own needs. A typical change, for example, is to adjust the Stop time parameter (in the Simulation Parameters dialog box) to a different value. Another common change is to specify the Fixed-step option in the Solver options panel to reflect the discrete-time nature of the DSP model.
2 Simulink and the DSP Blockset Using dspstartup.m There are two ways to use the dspstartup M-file to preconfigure Simulink for DSP simulations: • Run it from the MATLAB command line, by typing dspstartup, to preconfigure all of the models that you subsequently create. Existing models are not affected. • Place a call to dspstartup within the startup.m file. This is an efficient way to use dspstartup if you would like these settings to be in effect every time you start Simulink.
Configuring Simulink for DSP Systems Performance-Related Settings A number of the settings in the dspstartup M-file are chosen to improve the performance of the simulation: • 'SaveTime' is set to 'off' When 'SaveTime' is set to 'off', Simulink does not save the tout time-step vector to the workspace. The time-step record is not usually needed for analyzing discrete-time simulations, and disabling it saves a considerable amount of memory, especially when the simulation runs for an extended period of time.
2 Simulink and the DSP Blockset duration of the simulation. Simulink additionally precomputes the outputs of all downstream blocks driven exclusively by constant blocks. In the example below, the input to the top port (U) of the Matrix Multiply block is computed only once, at the start of the simulation. precomputed This eliminates the computational overhead of continuously reevaluating these constant branches, which in turn results in faster simulation, and smaller and more efficient generated code.
Configuring Simulink for DSP Systems of servicing the loop in cases when inline code can be used with only a modest increase in the file size. However, because typical DSP processors offer zero-overhead looping, code size is the primary optimization constraint in most designs. It is therefore more efficient to minimize code size by generating a loop for every instance of iteration, regardless of the number of repetitions. This is what the 'RTWOptions' loop-rolling setting in dspstartup accomplishes.
2 Simulink and the DSP Blockset 2-16
3 Working with Signals Overview . . . . . . . . . . . . . . . . . . . . . 3-2 Signal Concepts . . . . . . . . . . . . . . . . . . 3-3 Sample Rates and Frame Rates . . . . . . . . . . . 3-16 Creating Signals . . . . . . . . . . . . . . . . . . 3-33 Constructing Signals . . . . . . . . . . . . . . . . 3-42 Deconstructing Signals . . . . . . . . . . . . . . . 3-54 Importing Signals . . . . . . . . . . . . . . . . . 3-62 Exporting Signals . . . . . . . . . . . . . . . . . 3-72 Viewing Signals . . . .
3 Working with Signals Overview The first part of this chapter will help you understand how signals are represented in Simulink.
Signal Concepts Signal Concepts Simulink models can process both discrete-time and continuous-time signals, although models that are built with the DSP Blockset are often intended to process only discrete-time signals.
3 Working with Signals The following sections provide definitions for a number of terms commonly used to describe the time and frequency characteristics of discrete-time signals, and explain how these characteristics relate to Simulink models: • “Time and Frequency Terminology” • “Discrete-Time Signals in Simulink” Time and Frequency Terminology A number of different terms are used to describe the characteristics of discrete-time signals found in Simulink models.
Signal Concepts Term Symbol Units Notes Normalized frequency fn Two cycles per sample Frequency (linear) of a periodic signal normalized to half the sample rate, fn = ω/π = 2f/Fs. Angular frequency Ω Radians per second Frequency of a periodic signal in angular units, Ω = 2πf. Digital (normalized angular) frequency ω Radians per sample Frequency (angular) of a periodic signal normalized to the sample rate, ω = Ω/Fs = πfn.
3 Working with Signals The following sections explain the parameters available in this dialog box: • “Recommended Settings for Discrete-Time Simulations” • “Sample Time Offsets” • “Cross-Rate Operations in Variable-Step and Fixed-Step SingleTasking Modes” • “Sample Time Offsets” Recommended Settings for Discrete-Time Simulations.
Signal Concepts Additional Settings for Discrete-Time Simulations. It is worthwhile to know how the other solver options available in Simulink affect discrete-time signals.
3 Working with Signals Note In the recommended dspstartup settings, SingleTask rate transition is set to Error in the Diagnostics pane in the Simulation Parameters dialog box. Thus, in the dspstartup configurations, cross-rate operations will generate errors even though the solver is in fixed-step single-tasking mode. Example: Cross-Rate Operations. Consider the model below, which sums two signals having different sample periods. The fast signal (Ts=1) has sample times 1, 2, 3, ...
Signal Concepts moment inbetween because Simulink implicitly auto-promotes the rate of the slower signal to match the rate of the faster signal before the addition operation is performed. In general, for Variable-step and Fixed-step SingleTasking modes, when you measure the value of a discrete signal between sample times, you are observing the value of the signal at the previous sample time. Sample Time Offsets.
3 Working with Signals discrete-time blocks, you may need to interpose a Zero-Order Hold block to discretize the signal (see the following diagram). Specify the desired sample period for the signal in the Sample time parameter of the Zero-Order Hold block. Wrong: Error: Continuous sample times not allowed for upsample blocks. Correct: The Triggered Signal From Workspace block is also a continuous-time block. Discrete-Time Source Blocks.
Signal Concepts Multichannel Signals The following figure shows the prototypical discrete-time signal discussed in “Discrete-Time Signals” on page 3-3. If this signal were propagated through a model sample-by-sample, rather than in batches of samples, it would be called sample-based. It would also be called single-channel, because there is only one independent sequence of numbers.
3 Working with Signals 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 2 2 3 2 2 sample 4 (u t=3) 3 2 2 2 22 2 4 2 3 3 2 2 2 3 3 2 2 2 3 3 2 2 3 3 2 3 3 2 2 sample 3 (u t=2) 3 3 A sequence of sample-based matrices. Each of the 24 elements in a given matrix represents a single channel. 3 2 sample 2 (u t=1) 2 2 2 2 2 2 1 21 2 1 1 2 2 1 1 2 2 1 1 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 sample 1 (u t=0) Then the signal in channel 1 is composed of the following sequence.
Signal Concepts (or time slice) from N distinct signal channels, and each matrix column represents M consecutive samples from a single channel. This is a simple structure, as illustrated below for a sample 6-by-4 frame matrix.
3 Working with Signals • “Importing Signals” on page 3-62 • “Exporting Signals” on page 3-72 • “Viewing Signals” on page 3-80 Benefits of Frame-Based Processing Frame-based processing is an established method of accelerating both real-time systems and simulations. Accelerating Real-Time Systems Framed-based data is a common format in real-time systems.
Signal Concepts Sample-based operation ISR time acquire sample Frame-based operation acquire 16 samples ISR time latency It’s important to note that frame-based processing will introduce a certain amount of latency into a process due to the inherent lag in buffering the initial frame. In many instances, however, it is possible to select frame sizes that improve throughput without creating unacceptable latencies. Accelerating Simulations Simulation also benefits from frame-based processing.
3 Working with Signals Sample Rates and Frame Rates Sample rates are an important issue in most DSP models, especially in systems incorporating rate conversions. Fortunately, in most cases, when you build a Simulink model you only need to worry about setting sample rates in the source blocks, such as Signal From Workspace; Simulink automatically computes the appropriate sample rates for all downstream blocks.
Sample Rates and Frame Rates where Mi and Mo are the input and output frame sizes, respectively. The illustration below shows a one-channel frame-based signal with a frame size (Mi) of 4 and a frame period (Tfi) of 1. The sample period, Tsi, is therefore 1/ 4, or 0.25 seconds. A Probe block connected to this signal would display the frame period Tfi = 1. Tfi = 1 Tsi = 0.
3 Working with Signals The block displays the label Ts or Tf, followed by a two-element vector. The first (left) element is the period of the signal being measured. The second (right) is the signal’s sample time offset, which is usually 0, as explained in “Sample Time Offsets” on page 3-9. For sample-based signals, the value shown in the Probe block icon is the sample period of the sequence, Ts. For frame-based signals, the value shown in the Probe block icon is the frame period, Tf.
Sample Rates and Frame Rates Note that the sample rate conversion is implemented through a change in the frame period rather than the frame size. This is because the Frame-based mode parameter in the Upsample blocks is set to Maintain input frame size rather than Maintain input frame rate. See “Converting Sample Rates and Frame Rates” on page 3-20 for more information.
3 Working with Signals Because the Frame-based mode parameter in the Upsample blocks is set to Maintain input frame size rather than Maintain input frame rate, each Upsample block changes the frame rate. Therefore, each frame-based signal in the model is assigned a different color. If the Upsample blocks are instead set to Maintain input frame rate, then every signal in the model shares the same frame rate, and as a result, every signal is coded with the same color.
Sample Rates and Frame Rates • Direct rate conversions Direct rate conversions, such as upsampling and downsampling, are a feature of most DSP systems, and can be implemented by altering either the frame rate or the frame size of a signal. • Frame rebuffering The principal purpose of frame rebuffering is to alter the frame size of a signal, usually to improve simulation throughput.
3 Working with Signals Rate Conversion Blocks. The following table lists the principal rate conversion blocks in the DSP Blockset. Blocks marked with an asterisk (*) offer the option of changing the rate by either adjusting the frame size or frame rate.
Sample Rates and Frame Rates The sample period and frame size of the original signal are set to 0.125 seconds and 8 samples per frame, respectively, by the Sample time and Samples per frame parameters in the Signal From Workspace block. This results in a frame rate of 1 second (0.125∗8), as shown by the first Probe block. The Downsample block is configured to downsample the signal by changing the frame rate rather than the frame size. The dialog box with this setting is shown below.
3 Working with Signals As before, the frame rate of the original signal is 1 second (0.125∗8), shown by the first Probe block. Now the Downsample block is configured to downsample the signal by changing the frame size rather than the frame rate. The dialog box with this setting is shown below. Maintain input frame rate: Downsample the signal by changing the frame size.
Sample Rates and Frame Rates However, this is only true when the original signal is preserved in the buffering operation, with no samples added or deleted. Buffering operations that generate overlapping frames, or that only partially unbuffer frames, alter the data sequence by adding or deleting samples. In such cases, the above relation is not valid. Buffering Blocks. The following table lists the principal buffering blocks in the DSP Blockset.
3 Working with Signals The Buffer block preserves the signal’s data and sample period only when its Buffer overlap parameter is set to 0. The output frame period, Tfo, is M o T fi T fo = ---------------Mi where Tfi is the input frame period, Mi is the input frame size, and Mo is the output frame size specified by the Buffer size parameter.
Sample Rates and Frame Rates • Buffer adds duplicate samples to a sequence when the Buffer overlap parameter, L, is set to a nonzero value. The output frame period is related to the input sample period by T fo = ( M o – L )T si where Mo is the output frame size specified by the Buffer size parameter.
3 Working with Signals Example: Buffering with Alteration of the Signal. In the model below, a signal with a sample period of 0.125 seconds is rebuffered from a frame size of 8 to a frame size of 16 with an overlap of 4. The relation for the output frame period for the Buffer block is T fo = ( M o – L )T si which indicates that Tfo should be (16-4)∗0.125, or 1.5 seconds, as confirmed by the second Probe block. The sample period of the signal at the output of the Buffer block is no longer 0.
Sample Rates and Frame Rates To build the model, configure one Sine Wave block with Frequency = 1, and the other with Frequency = 2. In addition, both Sine Wave blocks should have the following settings: • Sample time = 0.1 • Samples per frame = 128 The frame period of the resulting summed sinusoid is 12.8 seconds (i.e., 128∗0.1), which is confirmed by the Probe block when the model is updated. Select Inherit FFT length from input dimensions in the Magnitude FFT block.
3 Working with Signals The Vector Scope block uses the input frame size (128) and period (12.8) to deduce the original signal’s sample period (0.1), which allows it to correctly display the peaks at 1 Hz and 2 Hz. Example 2: Unintended Rate Conversion. Now alter the previous example by setting the Magnitude FFT block parameters as follows: • Deselect the Inherit FFT length from input dimensions check box. • Set the FFT length parameter to 256.
Sample Rates and Frame Rates In this case, based on the input frame size (256) and period (12.8), the Vector Scope block calculates the original signal’s sample period to be 0.05 seconds (12.8/256), which is wrong. As a result, the spectral peaks appear at the incorrect frequencies, 2 Hz and 4 Hz rather than 1 Hz and 2 Hz. The problem is that the zero-pad operation performed by the Magnitude FFT block halves the sample period of the sequence by appending 128 zeros to each frame.
3 Working with Signals convert a frame-based signal to a sample-based signal is by using the Unbuffer block. See the following sections for more information about these methods: • “Buffering Sample-Based and Frame-Based Signals” on page 3-47 • “Unbuffering a Frame-Based Signal into a Sample-Based Signal” on page 3-60 On occasion it may be desirable to change the frame status of a signal without performing a buffering operation.
Creating Signals Creating Signals There are a variety of different ways to create signals using Simulink and DSP blocks. The following sections explore the most common techniques: • “Creating Signals Using Constant Blocks” on page 3-33 • “Creating Signals Using Signal Generator Blocks” on page 3-36 • “Creating Signals Using the Signal From Workspace Block” on page 3-38 The above sections discuss creating signals (single-channel and multichannel) using source blocks.
3 Working with Signals • “Creating Signals Using the Signal From Workspace Block” on page 3-38 For information about importing signals, see the following sections: • “Importing a Multichannel Sample-Based Signal” on page 3-62 • “Importing a Multichannel Frame-Based Signal” on page 3-68 Example: Creating Signals with the DSP Constant Block The DSP Constant block has the following parameters: • Constant value • Interpret vector parameters as 1-D • Sample mode • Sample time • Frame-based output To generate
Creating Signals output check box selected, and the fourth block (DSP Constant3) has the Interpret vector parameters as 1-D check box selected.
3 Working with Signals block is selected. This means that the output is not a matrix. However, most nonsource DSP blocks interpret a length-M 1-D vector as an M-by-1 matrix (column vector). Note A 1-D vector signal must always be sample-based. The Interpret vector parameters as 1-D parameter is ignored when Frame-based output is selected, or when a matrix is specified for the Constant value parameter.
Creating Signals • Amplitude • Frequency • Phase offset • Sample time • Samples per frame In the model below, a Sine Wave block generates a frame-based (multichannel) matrix containing three independent signals: • Sine wave of amplitude 1 and frequency 100 Hz • Sine wave of amplitude 3 and frequency 250 Hz • Sine wave of amplitude 2 and frequency 500 Hz Each channel has a frame size of 64 samples. The three signals are summed point-by-point by a Matrix Sum block, and exported to the workspace.
3 Working with Signals 6 4 2 0 −2 −4 −6 0 20 40 60 80 100 See “Multichannel Signals” on page 3-11 for more information about the representation of sample-based and frame-based data. Creating Signals Using the Signal From Workspace Block You can easily create custom signals using the Signal From Workspace block.
Creating Signals For more information about creating signals, see the following sections: • “Creating Signals Using Constant Blocks” on page 3-33 • “Creating Signals Using Signal Generator Blocks” on page 3-36 Example 1: Generating Sample-Based Output In the model below, the Signal From Workspace creates a four-channel sample-based signal with the following data: • Channel 1: 1, 2, 3, 0, 0,... • Channel 2: -1, -2, -3, 0, 0,... • Channel 3: 0, 0, 0, 0, 0,... • Channel 4: 5, 5, 5, 0, 0,...
3 Working with Signals • Channel 1: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0,... 0 0 0 0 0 0 0 0 t=12 9 10 0 0 1 1 0 0 t=8 5 6 7 8 1 1 0 0 t=4 ch1 ch2 ch1 ch2 ch1 ch2 ch1 ch2 • Channel 2: 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0,...
Creating Signals yout = 1 2 3 4 5 6 7 8 9 10 0 0 1 1 0 0 1 1 0 0 1 1 0 0 3-41
3 Working with Signals Constructing Signals When you want to perform a given sequence of operations on several independent signals, it is frequently very convenient to group those signals together as a multichannel signal. Most DSP blocks accept multichannel signals, and process each channel independently. By taking advantage of this capability, you can do the same job with fewer blocks and have a cleaner, leaner model.
Constructing Signals Constructing Sample-Based Multichannel Signals from Independent Sample-Based Signals You can combine individual sample-based signals into a multichannel signal by using the Matrix Concatenation block in Simulink’s Sources library. Example: Concatenating Single-Channel Signals. In the model below, four independent sample-based signals are combined into a 2-by-2 multichannel matrix signal.
3 Working with Signals Each 4-by-1 output from the Matrix Concatenation block contains one sample from each of the four input signals. All four samples in the output correspond to the same instant in time. The Reshape block simply rearranges the samples into a 2-by-2 matrix. Note that the Reshape block works columnwise, so that a column vector input is reshaped as shown below. 1 2 3 4 1 3 2 4 The 4-by-1 matrix and the 2-by-2 matrix in the above model represent the same sample-based four-channel signal.
Constructing Signals • In Signal From Workspace1, set Signal = [zeros(10,1) 5*ones(10,1)] • In Matrix Concatenation, set: - Number of inputs = 2 - Concatenation method = Vertical Each 2-by-2 output from the Matrix Concatenation block contains both samples from each of the two input signals, so that all four samples in the output correspond to the same instant in time. See “Sample-Based Multichannel Signals” on page 3-11 for more about sample-based signals.
3 Working with Signals frame-based signals using the Buffer block in the Buffers library (in Signal Management).
Constructing Signals 1 2 3 4 –1 –2 –3 –4 5 5 5 5 2-channel frame-based signal (top) and 1-channel frame-based signal (bottom) 1 2 3 4 –1 –2 –3 –4 5 5 5 5 3-channel frame-based signal To build the model, make the following parameter settings: • In Signal From Workspace, set Signal = [1:10;-1:-1:-10]' • In Signal From Workspace1, set Signal = 5*ones(10,1) • In Matrix Concatenation, set: - Number of inputs = 2 - Concatenation method = Horizontal The 4-by-3 matrix output from the Matrix Concatenation bl
3 Working with Signals • Output buffer size (per channel), Mo • Buffer overlap, L • Initial conditions Buffering an N-channel (1-by-N or N-by-1) sample-based signal produces a Mo-by-N frame-based signal. Buffering an Mi-by-N frame-based signal (N channels and Mi samples per frame) results in an Mo-by-N output frame-based signal. For each output buffer, the block acquires the number of new input samples specified by the difference between the Buffer size (Mo) and Buffer overlap (L) parameters.
Constructing Signals • “Example: Buffering Frame-Based Signals with Overlap” on page 3-52 • “Buffering Delay and Initial Conditions” on page 3-53 Example: Buffering Sample-Based Signals without Overlap. In the model below, a two-channel sample-based signal is buffered into a two-channel frame-based signal.
3 Working with Signals • “Importing a Multichannel Frame-Based Signal” on page 3-68 Overlapping Buffers. In some cases it is useful to work with data that represents overlapping sections of an original sample-based or frame-based signal. In estimating the power spectrum of a signal, for example, it is often desirable to compute the FFT of overlapping sections of data. Overlapping buffers are also needed in computing statistics on a sliding window, or for adaptive filtering.
Constructing Signals ch2 ch1 ch3 ch4 Sample-based input, t=5 6 1 5 –6 t=4 5 1 5 –5 t=3 4 0 5 –4 t=2 3 0 5 –3 t=1 2 1 5 –2 t=0 1 1 5 –1 sample period = Tsi Tsi = 1 Frame-based output , frame period = (Mo-L)∗Tsi ch1 ch2 ch3 ch4 ch1 ch2 ch3 ch4 (Mo=3, L=1) first frame-based output ch1 ch2 ch3 ch4 first sample-based input 4 0 5 –4 5 1 5 –5 6 1 5 –6 2 1 5 –2 3 0 5 –3 4 0 5 –4 0 0 0 0 1 1 5 –1 2 1 5 –2 0000 0000 0000 t=6 t=4 t=2 t=0 To build the model, define the following variable
3 Working with Signals ch1 ch2 (Mo=3, L=1) ch1 ch2 t=0 ch1 ch2 1 1 0 0 ch1 ch2 t=4 1 2 3 4 ch1 ch2 1 1 0 0 ch1 ch2 5 6 7 8 ch1 ch2 ch1 ch2 Example: Buffering Frame-Based Signals with Overlap. In the model below, a two-channel frame-based signal with frame period 4 is rebuffered to a frame-based signal with frame size 3 and frame period 2. Because of the overlap, the input sample period is not conserved, and the output sample period is 2/3.
Constructing Signals Buffering Delay and Initial Conditions. In both of the previous buffering examples the input signal is delayed by a certain number of samples. In “Example: Buffering Sample-Based Signals with Overlap” the delay is four samples. In “Example: Buffering Frame-Based Signals with Overlap” the delay is eight samples. The initial output samples adopt the value specified for the Initial condition parameter, which is zero in both examples above.
3 Working with Signals Deconstructing Signals Multichannel signals, represented by matrices in Simulink, are frequently used in DSP models for efficiency and compactness. An M-by-N sample-based multichannel signal represents M*N independent signals (one sample from each), whereas an M-by-N frame-based multichannel signal represents N independent channels (M consecutive samples from each). See “Multichannel Signals” on page 3-11 for more information about the matrix format.
Deconstructing Signals in the Indexing library (in Signal Management). Any subset of rows or columns can be selected for propagation to a given output port. Example: Deconstructing to Independent Signals. In the model below, a six-channel sample-based signal (3-by-2 matrix) is deconstructed to yield three independent sample-based signals. Two of the output signals have four channels, and the third signal has two channels.
3 Working with Signals • Variable Selector The next section provides an example of using the Submatrix block to extract a portion of a multichannel sample-based signal. The Submatrix block is the most versatile of the above blocks in that it allows you to make completely arbitrary channel selections. Example: Deconstructing to a Multichannel Signal.
Deconstructing Signals Deconstructing Multichannel Frame-Based Signals A frame-based signal with N channels and frame size M is represented by a sequence of M-by-N matrices. (The special case of N = 1 represents a single-channel signal.
3 Working with Signals sample 6 6 6 sample 5 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 6 5 6 5 sample 4 5 4 sample 3 5 4 4 3 sample 2 sample 1 4 3 3 2 3 2 1 2 1 2 1 1 ch1 ch2 ch3 ch4 ch1 ch2 ch3 ch4 Multichannel frame-based signal : Multichannel sample-based signal : 4 channels, 6 samples per frame 4 channels The following sections explain the two methods of deconstructing multichannel frame-based signals: • “Splitting a Multichannel Signal into
Deconstructing Signals 1 2 3 4 –1 –2 –3 –4 1 2 3 4 5 5 5 5 3-channel frame-based signal 5 5 5 5 –1 –2 –3 –4 2-channel frame-based signal (top) and 1-channel frame-based signal (bottom) To build the model, make the following parameter settings: • In Signal From Workspace, set: - Signal = [1:10;-1:-1:-10;5*ones(1,10)]' - Samples per frame = 4 • In Multiport Selector, set: - Select = Columns - Indices to output = {[1 3],2} The top (4-by-2) output from the Multiport Selector block contains the first an
3 Working with Signals Unbuffering a Frame-Based Signal into a Sample-Based Signal You can unbuffer a multichannel frame-based signal into a multichannel sample-based signal by using the Unbuffer block in the Buffers library (in Signal Management). The Unbuffer block performs the inverse operation of the Buffer block’s “sample-based to frame-based” buffering process, and generates an N-channel sample-based output from an N-channel frame-based input.
Deconstructing Signals The Signal From Workspace block generates a two-channel frame based-signal with frame size 4 (because the Samples per frame parameter is set to 4). The Unbuffer block unbuffers this signal to a two-channel sample-based signal. Note The Unbuffer block generates initial conditions (not shown in the figure above) with the value specified by the Initial conditions parameter. See the Unbuffer reference page for information about the number of initial conditions that appear in the output.
3 Working with Signals Importing Signals Although a number of signal generation blocks are available in Simulink and the DSP Blockset, it is very common to import custom signals from the MATLAB workspace as well.
Importing Signals Sample-time parameter specifies the sample period of the sample-based output. See “Sample-Based Multichannel Signals” on page 3-11 for general information about sample-based signals.
3 Working with Signals containing M consecutive samples. In other words, the workspace matrix must be oriented so as to have the independent channels as its columns. When the block has output all of the rows available in the specified variable, it can start again at the beginning of the signal, or simply repeat the final value (or generate zeros) until the end of the simulation. This behavior is controlled by the Form output after final data value by parameter.
Importing Signals • Form output after final data value = Setting to zero The Signal expression [A B] uses the standard MATLAB syntax for horizontally concatenating matrices and appends column vector B to the right of matrix A. Equivalently, you could set Signal = C, and define C at the command line by C = [A B] The Sample time setting of 1 yields a sample-based output with sample period of 1 second.
3 Working with Signals 5 5 5 4 2 3 5 4 2 3 4 2 5 3 4 2 5 3 4 2 5 4 3 3 5 4 2 2 23 2 2 22 2 1 2 22 2 1 2 22 2 1 2 2 2 21 2 1 1 5 4 2 2 23 2 2 22 2 1 2 22 2 1 2 22 2 1 2 2 2 21 2 1 1 4 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 4 4 4 4 4 2 4 4 4 4 4 3 2 1 2 1 2 1 2 1 2 2 1 1 2 2 1 2 1 sample 4 3 3 2 3 3 2 2 3 3 3 3 2 2 2 22 2 4 2 3 3 2 2 2 3 3 2 2 2 3 3 2 2 3 2 sample 3 2 1 2 1 2 1 1 3 2 2 sample 2 2 2 2 2 2 2 2 2 1 21 2 1 1 2 2 1 1 2 2 1 1 2 2 2 2 1 1 1 1 1 1 1 1 1
Importing Signals • Channel 3: 0, 0, 0, 0, 0,... • Channel 4: 5, 5, 5,..., 0, 0, 0,... 4 –4 0 5 3 –3 0 5 2 –2 0 5 1 –1 0 5 t=3 t=2 t=1 t=0 first matrix output Four consecutive samples from a 4-channel sample-based signal To create the model, define the following variables at the MATLAB command line.
3 Working with Signals • “Constructing Multichannel Sample-Based Signals” on page 3-42 Importing a Multichannel Frame-Based Signal The Signal From Workspace in the DSP Sources library is the key block for importing frame-based signals from the MATLAB workspace. The dialog box has the following parameters: • Signal • Sample time • Samples per frame • Form output after final data value by Use the Signal parameter to specify the name of a variable (vector or matrix) in the MATLAB workspace.
Importing Signals Beginning with the first M rows of the matrix, the block releases M rows of the matrix (i.e., one frame from each channel) to the output every M∗Ts seconds. Therefore, if the Signal parameter specifies a W-by-N workspace matrix, the output of the Signal From Workspace block is an M-by-N matrix representing N channels. The figure below illustrates this for a 6-by-4 workspace matrix, A, and a frame size of 2.
3 Working with Signals by the Form output after final data value by parameter. See the Signal From Workspace reference page for more information. The following example illustrates how the Signal From Workspace block is used to import a frame-based multichannel signal into a model. Example: Importing a Frame-Based Signal. In the model below, the Signal From Workspace creates a three-channel frame-based signal with the following data: • Channel 1: 1, 2, 3, 4, 5,..., 100, 0, 0, 0,...
Importing Signals The Signal expression [A B] uses the standard MATLAB syntax for horizontally concatenating matrices and appends column vector B to the right of matrix A. Equivalently, you could set Signal = C, and define C at the command line by C = [A B] The Sample time setting of 1 and Samples per frame setting of 4 yield a frame-based output with sample period of 1 second and frame period of 4 seconds.
3 Working with Signals Exporting Signals The To Workspace and Triggered To Workspace blocks are the primary conduits for exporting signals from a Simulink model to the MATLAB workspace.
Exporting Signals to downsample a signal before exporting to the workspace, consider using the Downsample or FIR Decimation blocks. See “Converting Sample Rates and Frame Rates” on page 3-20 for more information about rate conversion. The Save format parameter allows you to save the output in a variety of formats. The default is Array, which is also generally the most accessible output format.
3 Working with Signals 2 2 2 3 3 3 3 3 3 4 2 2 2 42 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 2 2 2 3 3 3 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 2 2 31 3 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 3 3 3 3 2 2 2 2 2 2 5 5 4 2 3 5 4 2 3 4 2 5 3 4 2 5 3 4 2 5 4 3 3 5 sample 1 sample 2 sample 3 sample 4 5 4 2 2 23 2 2 22 2 1 2 22 2 1 2 22 2 1 2 2 2 21 2 1 1 5 4 2 2 23 2 2 22 2 1 2 22 2 1 2 22 2 1 2 2 2 21 2 1 1 4 2 2 2 2 2 2 2 2 2 2 3 2 1 2 1 2 1 2 1
Exporting Signals 4 –4 0 5 3 –3 0 5 2 –2 0 5 1 –1 0 5 t=3 t=2 t=1 t=0 first matrix output Four consecutive samples from a 4-channel sample-based signal To create the model, define the following variables at the MATLAB command line.
3 Working with Signals yout(:,:,1:4) ans(:,:,1) = 1 0 -1 5 ans(:,:,2) = 2 0 -2 5 ans(:,:,3) = 3 0 -3 5 ans(:,:,4) = 4 0 -4 5 Exporting a Frame-Based Signal Using the To Workspace Block Recall that a frame-based signal with N channels and frame size M is represented by a sequence of M-by-N matrices. (The special case of N = 1 represents a single-channel signal.
Exporting Signals 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 sample 1 sample 2 sample 3 sample 4 sample 5 sample 6 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 ch1 ch2 ch3 ch4 ch1 ch2 ch3 ch4 Frame-based signal : 4 channels, 2 samples per frame MATLAB workspace matrix, A : 4 channels The workspace matrix always has time running along its first (P) dimension.
3 Working with Signals To create the model, define the following variables at the MATLAB command line. A = [1:100;-1:-1:-100]'; B = 5*ones(100,1); % 100-by-2 matrix % 100-by-1 column vector Matrix A represents a two-channel signal with 100 samples, and matrix B represents a one-channel signal with 100 samples.
Exporting Signals The following two sections may also be of interest: • “Creating Signals Using the Signal From Workspace Block” on page 3-38 • “Constructing Multichannel Sample-Based Signals” on page 3-42 Exporting and Playing WAV Files The key blocks for exporting and playing WAV audio files are: • To Wave Device • To Wave File The To Wave Device and To Wave File blocks are limited to one-channel (mono) or two-channel (stereo) inputs, selectable in the Stereo check box.
3 Working with Signals Viewing Signals The following blocks in the DSP Sinks library are the key blocks for displaying signals: • Matrix Viewer • Spectrum Scope • Time Scope (Simulink Scope) • Vector Scope The following sections provide an introduction to how these blocks are commonly used: • “Displaying Signals in the Time-Domain” on page 3-80 • “Displaying Signals in the Frequency-Domain” on page 3-82 • “Displaying Matrices” on page 3-83 Displaying Signals in the Time-Domain The Vector Scope block can
Viewing Signals Specify the following parameter values in the Signal From Workspace block: • Signal = mtlb • Sample time = 1 • Samples per frame = 16 • Form output after final data value = Cyclic Repetition Specify the following parameter values in the Digital Filter Design block: • Filter Type = Lowpass • Design Method = FIR (Window) • Filter Order (Specify order) = 22 • Window Specifications (Window) = Hamming • Frequency Specifications (wc) = 0.
3 Working with Signals • Select Compact display from the right-click menu to allow the scope to use all the available space in the window. • Select CH 1 from the right-click menu, and then select Marker and “o” from the submenus, to mark the data points on the channel 1 signal with circles. • Select CH 1 from the right-click menu, and then select Color and Blue from the submenus, to code the channel 1 signal with the color blue.
Viewing Signals • Filter Type = Lowpass • Design Method = FIR (Window) • Filter Order (Specify order) = 22 • Window Specifications (Window) = Hamming • Frequency Specifications (wc) = 0.
3 Working with Signals To build the model, specify the following parameter values in the Sine Wave block: • Amplitude = 1 • Frequency = 100 • Phase offset = 0:pi/64:pi Specify the following parameter values in the Submatrix block: • Row span = All rows • Column span = Range of columns • Starting column = First • Ending column = Offset from last • Ending column offset = 1 Specify the following parameter values in the Reshape block: • Output dimensionality = Customize • Output dimensions = [8,8] Specify Col
Delay and Latency Delay and Latency There are two distinct types of delay that affect Simulink models: • Computational delay • Algorithmic delay The following sections explain how you can configure Simulink to minimize both varieties of delay and increase simulation performance. Computational Delay The computational delay of a block or subsystem is related to the number of operations involved in executing that component.
3 Working with Signals A first step in improving performance is to analyze your model, and eliminate or simplify elements that are adding excessively to the computational load. Such elements might include scope displays and data logging blocks that you had put in place for debugging purposes and no longer require. In addition to these model-specific adjustments, there are a number of more general steps you can take to improve the performance of any model: • Use frame-based processing wherever possible.
Delay and Latency input. This delay is directly related to the time elapsed on the Simulink timer during that block’s execution. The algorithmic delay of a particular block may depend on both the block’s parameter settings and the general Simulink settings.
3 Working with Signals Use the default settings for the Normalization, Digital Clock, Mux, and To Workspace blocks, and adjust the Signal From Workspace block parameters as follows: • Signal = 1:100 • Sample time = 1/4 • Samples per frame = 4 Select Sample-based from the Output signal menu in the Frame Status Conversion block. Note that the current value of the Simulink timer (from the Digital Clock block) is prepended to each output frame.
Delay and Latency The first column of ans is the Simulink time provided by the Digital Clock block. You can see that the squared 2-norm of the first input, [1 2 3 4]' ./ sum([1 2 3 4]'.^2) appears in the first row of the output (at time t=0), the same time step that the input was received by the block. This indicates that the Normalization block has zero algorithmic delay. Zero Algorithmic Delay and Algebraic Loops.
3 Working with Signals Use the default settings for the Digital Clock, Mux, and To Workspace blocks, and adjust the Signal From Workspace block’s parameters to the values below: • Signal = 1:100 • Sample time = 1 • Samples per frame = 1 Set the DSP Constant block’s Constant value parameter to 3, and set the Variable Integer Delay block’s Initial conditions parameter to -1. Now run the simulation and look at the output, yout. The first few samples are shown below.
Delay and Latency Excess Algorithmic Delay (Tasking Latency) Under certain conditions, Simulink may force a block to delay inputs longer than is strictly required by the block’s algorithm. This excess algorithmic delay is called tasking latency, because it arises from synchronization requirements of Simulink’s tasking mode. A block’s overall algorithmic delay is the sum of its basic delay and tasking latency.
3 Working with Signals block is called multirate when at least one input or output port has a different frame rate than the others. Many blocks are permanently single-rate, which means that all input and output ports always have the same frame rate. For other blocks, the block parameter settings determine whether the block is single-rate or multirate. Only multirate blocks are subject to tasking latency.
Delay and Latency Example: Nonzero Tasking Latency. Most multirate blocks experience tasking latency only in Simulink’s multitasking mode. As an example, consider the following model. To engage Simulink’s multitasking mode, adjust the following settings in the Solver panel of the Simulation Parameters dialog box: • Type = Fixed-step • Mode = MultiTasking Use the default settings for the Mux and To Workspace blocks.
3 Working with Signals • Set the Output signal parameter of the Frame Status Conversion block to Sample-based. Notice that the current value of the Simulink timer (from the Digital Clock block) is prepended to each output frame. The frame-based signal is converted to a sample-based signal by the Frame Status Conversion block so that the output in the command window will be easily readable.
Delay and Latency ans = 0 0.2500 0.5000 0.7500 1.0000 1.2500 1.5000 1.7500 2.0000 time -1.0000 -1.0000 -1.0000 -1.0000 1.0000 2.0000 3.0000 4.0000 5.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1st output frame 0 0 0 0 5th output frame 0 0 0 0 The first column of yout is the Simulink time provided by the Digital Clock block. The four values to the right of each time are the values in the output frame at that time.
3 Working with Signals The “Latency and Initial Conditions” section of the reference page for Upsample indicates that the block has zero latency for all multirate operations in Simulink’s single-tasking mode. To verify this, look at the output from the simulation, squeeze(yout)'. The first few samples are shown below. ans = 0 0.2500 0.5000 0.7500 1.0000 1.2500 1.5000 1.7500 2.0000 time 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.
4 DSP Operations Overview . . . . . . . . . . . . . . . . . . . . . 4-2 Filters . . . . . . . . . . . . . . . . . . . . . . . 4-3 Transforms . . . . . . . . . . . . . . . . . . . . 4-10 Power Spectrum Estimation . . . . . . . . . . . . . 4-15 Linear Algebra . . . . . . . . . . . . . . . . . . . 4-16 Statistics . . . . . . . . . . . . . . . . . . . . . 4-21 DSP Blockset Demos Overview . . . . . . . . . . .
4 DSP Operations Overview This chapter discusses some basic DSP operations, and how they can be implemented using the DSP Blockset. The following topics are covered: • “Filters” • “Transforms” • “Power Spectrum Estimation” • “Linear Algebra” • “Statistics” The discussion and examples included in these sections should help you become familiar with the standard operations involved in simulating DSP models.
Filters Filters Filtering is one of the most important operations in signal processing, and is supported in the DSP Blockset with three libraries of filtering blocks. The following sections present a brief overview of these libraries: • “Adaptive Filters” on page 4-3 • “Filter Designs” on page 4-4 • “Multirate Filters” on page 4-9 All libraries are located within the top-level Filtering library.
4 DSP Operations Filter Designs Filter Designs library blocks apply specified filters to an input signal and output the result. Depending on the block, you specify a filter with its filter coefficients, or by setting filter specification parameters. The following table categorizes Filter Designs library blocks by the types of filters they implement.
Filters For details about a particular block, consult its reference page.
4 DSP Operations The FDATool GUI Opened from the Digital Filter Design Block Designing Filters with Various Filter Structures Any realizable filter can be represented in the time domain by a difference equation of the form y(k) = b 1 u(k) + b 2 u(k – 1) + L + b m u(k – m – 1) – a 2 y(k – 1) – … – a n y ( k – n – 1 ) 4-6
Filters where y(k) and u(k) are, respectively, the output and input at the current time step, y(k-1) and u(k-1) are the output and input at the previous time step, and so on. The values b1, b2, ..., bm, and a2, ..., an are the filter coefficients, or taps. Every realizable filter is therefore fundamentally a collection of multiplications, additions, and delays.
4 DSP Operations you specify a filter order. The other available parameters depend on the filter type and band configuration, as shown in the table below.
Filters Note The Analog Filter Design block does not work with Simulink’s discrete solver, which is enabled when the discrete option is selected in the Solver panel of the Simulation Parameters dialog box. Select one of the continuous solvers (e.g., ode4) instead. Multirate Filters Multirate filters are those which alter the sample rate of the input signal during the filtering process. Such filters are useful in both rate conversion and filter bank applications.
4 DSP Operations Transforms The Transforms library provides blocks for a number of transforms that are of particular importance in DSP applications: • Analytic Signal • Complex Cepstrum • DCT • FFT • IDCT • IFFT • Real Cepstrum First and foremost among these are of course the FFT and IFFT blocks, which respectively implement the fast Fourier transform and its inverse. These blocks are discussed further in the next section.
Transforms To build the model, make the following parameter settings: • In the Sine Wave block, set: - Amplitude = 1 - Frequency = [15 40] - Phase offset = 0 - Sample time = 0.001 - Samples per frame = 128 • In the Matrix Sum block, set Sum along = Rows. • In the Complex to Magnitude-Angle block, set Output = Magnitude.
4 DSP Operations Note that the three-block sequence of FFT, Complex to Magnitude-Angle, and Vector Scope could be replaced by a single Spectrum Scope block, which computes the magnitude FFT internally. Other blocks that compute the FFT internally are the blocks in the Power Spectrum Estimation library. See “Power Spectrum Estimation” on page 4-15 for more information about these blocks.
Transforms - Input is in bit-reversed order = - Input is conjugate symmetric = • In the Sum block, set List of signs = |++. • In the Gain block, set Gain = -1. • In the Scope properties panel of the Vector Scope block, set Input domain = Time • Set the Stop time in the Parameters dialog box to inf, and start the simulation by selecting Start from the Simulation menu.
4 DSP Operations 4-14
Power Spectrum Estimation Power Spectrum Estimation The Power Spectrum Estimation library provides a number of blocks for spectral analysis.
4 DSP Operations Linear Algebra The Matrices and Linear Algebra library provides three large sublibraries containing blocks for linear algebra: • Linear System Solvers • Matrix Factorizations • Matrix Inverses A third library, Matrix Operations, provides other essential blocks for working with matrices. See “Multichannel Signals” on page 3-11 for more information about matrix signals.
Linear Algebra Example: LU Solver In the model below, the LU Solver block solves the equation Ax = b, where 1 –2 3 A = 4 0 6 2 –1 3 1 b = –2 –1 and finds x to be the vector [-2 0 1]'. To build the model, set the following parameters: • In the DSP Constant block, set Constant value = [1 -2 3;4 0 6;2 -1 3]. • In the DSP Constant1 block, set Constant value = [1 -2 -1]'. You can verify the solution by using the Matrix Multiply block to perform the multiplication Ax, as shown in the model below.
4 DSP Operations • QR Factorization • Singular Value Decomposition Some of the blocks offer particular strengths for certain classes of problems. For example, the Cholesky Factorization block is particularly suited to factoring a Hermitian positive definite matrix into triangular components, whereas the QR Factorization is particularly suited to factoring a rectangular matrix into unitary and upper triangular components.
Linear Algebra U = 4 0 0 0 –2 0 6 1.5 – 0.75 1 0 L = 0.25 1 0.5 0.5 0 0 1 You can check that LU = Ap with the Matrix Multiply block, as shown in the model below.
4 DSP Operations To build the model, in the DSP Constant block, set the Constant value parameter to [1 -2 3;4 0 6;2 -1 3]. As shown above, the computed inverse is A 4-20 –1 = – 1 – 0.5 2 0 0.5 –1 0.6667 0.5 – 1.
Statistics Statistics The Statistics library provides fundamental statistical operations such as minimum, maximum, mean, variance, and standard deviation.
4 DSP Operations selected, for example) the Maximum block finds the maximum value in each column of the current input, and returns this result at the top output (Val). Each consecutive Val output therefore has the same number of columns as the input, but only one row. Furthermore, the values in a given output only depend on the values in the corresponding input. The block repeats this operation for each successive input.
Statistics • In the Buffer block, set: - Output buffer size (per channel) = 128 - Buffer overlap = 127 Running Operations A running operation is one that processes successive sample-based or frame-based inputs, and computes a result that reflects both present and past inputs. A reset port enables you to restart this tracking at any time. The running statistic is computed for each input channel independently, so the block’s output is the same size as the input.
4 DSP Operations DSP Blockset Demos Overview You can access the DSP Blockset demos by typing demos at the MATLAB command line. In the Demos window that opens, expand the Blocksets entry by double-clicking, and then click DSP to see the demos. Explore all the demos to see how you can implement both basic and advanced DSP algorithms with the DSP Blockset. You can also use the demos as a base for building your own models.
DSP Blockset Demos Overview • LPC analysis and synthesis: Uses the Levinson solver and Time-Varying Lattice Filter for low-bandwidth transmission of speech.
4 DSP Operations Queues Demo • Demo uses a Queue block with a system of selection switches to illustrate pushing and popping elements from a queue. Sigma-Delta A/D Conversion Demo • Demo illustrates analog-to-digital conversion using a sigma-delta algorithm implementation. Sine Wave Generation Demo • Demo compares different sine wave generation systems. Spectral Analysis Demos • Short-time FFT: Uses the Short-Time FFT block to compute and display a spectrogram.
5 DSP Block Reference Features of the Online DSP Block Reference . . . Main Sections of a Block Reference Page . . . . . . . Ways to Access Online DSP Block Reference Pages . . . Running Example Code in the MATLAB Help browser . Running Example Models in the MATLAB Help browser . . . . . . . . . . 5-2 5-2 5-4 5-4 5-4 Blocks Supporting Code Generation . . . . . . . . . 5-6 Block Library List . . . . . . . . . . . . . . . . . 5-9 Block Library Hierarchy . . . . . . . . . . . . . . . .
5 DSP Block Reference Features of the Online DSP Block Reference The online DSP Blockset block reference section contains complete information on every block in the DSP Blockset in a structured, accessible format. Use this reference section when you need to find detailed information on a particular block.
Features of the Online DSP Block Reference About Tunable Parameters Tunable parameters are block parameters whose settings you can change or tune during a simulation. In the “Dialog Box” section of the block reference pages, these parameters are marked “Tunable” in the parameter descriptions. To tune a tunable parameter during a simulation, open the block parameters dialog, change the parameter to the desired setting, then press the OK or Apply button.
5 DSP Block Reference Ways to Access Online DSP Block Reference Pages There are several ways to access the reference pages: • Click Help in a block dialog box. • Right-click a block in a model, and select Help from the pop-up menu. • Right-click a block in the Simulink Library Browser, and select Help from the pop-up menu. (Open the library browser by typing simulink at the MATLAB command line.) • Type doc('block name') at the MATLAB command line.
Features of the Online DSP Block Reference • Click on indicated links to bring up example models. • Run the models as you would run any other model. Open the following model by clicking here in the MATLAB Help browser.
5 DSP Block Reference Blocks Supporting Code Generation You can generate C code from models containing DSP Blockset blocks by using the Real-Time Workshop. All DSP Blockset blocks support generic real-time (GRT) code generation. Many blocks also support embedded real-time (ERT) code generation, as indicated in the following table. See the Real-Time Workshop documentation for more information on generating code from Simulink models.
Blocks Supporting Code Generation DSP Blockset Blocks Supporting ERT Code Generation: Display Downsample DSP Constant Dyadic Analysis Filter Bank Dyadic Synthesis Filter Bank Edge Detector Event-Count Comparator Extract Diagonal Extract Triangular Matrix FFT Filter Realization Wizard FIR Decimation FIR Interpolation FIR Rate Conversion Flip Frame Status Conversion Histogram Identity Matrix IFFT Inherit Complexity Integer Delay Kalman Adaptive Filter LMS Adaptive Filter Magnitude FFT
5 DSP Block Reference DSP Blockset Blocks Supporting ERT Code Generation: 5-8 Real Cepstrum Repeat RLS Adaptive Filter RMS Sample and Hold Selector Short-Time FFT Signal From Workspace Signal To Workspace Sine Wave Sort Standard Deviation Submatrix Time Scope Time-Varying Direct-Form II Transpose Filter Time-Varying Lattice Filter Toeplitz Transpose Triggered Delay Line Triggered Signal From Workspace Triggered To Workspace Unbuffer Uniform Decoder Uniform Encoder Unwrap Upsampl
Block Library List Block Library List This section contains the following two subsections: • “Block Library Hierarchy” – a structured list of the DSP Blockset libraries • “Block Library Contents” – a listing of all DSP blocks, arranged by library See “Alphabetical List of Blocks” on page 5-18 for an alphabetical listing of blocks. The pages that follow that section contain reference information for all blocks in the DSP Blockset, arranged in alphabetical order by block name.
5 DSP Block Reference - Signal Management: Buffers - Signal Management: Indexing - Signal Management: Signal Attributes - Signal Management: Switches and Counters • Signal Operations • Statistics • Transforms Use the Simulink Library Browser to access the blockset directly through the above hierarchical library list. Block Library Contents The DSP blocks in each of these libraries are listed below.
Block Library List DSP Sources (Continued) DSP Constant Signal From Workspace Discrete Impulse Sine Wave From Wave Device Triggered Signal From Workspace From Wave File Window Function Estimation: Linear Prediction Autocorrelation LPC Estimation: Parametric Estimation Burg AR Estimator Modified Covariance AR Estimator Covariance AR Estimator Yule-Walker AR Estimator Estimation: Power Spectrum Estimation Burg Method Modified Covariance Method Covariance Method Short-Time FFT Magnitude F
5 DSP Block Reference Filtering: Adaptive Filters Kalman Adaptive Filter RLS Adaptive Filter LMS Adaptive Filter Filtering: Filter Designs Analog Filter Design Overlap-Add FFT Filter Biquadratic Filter Overlap-Save FFT Filter Digital Filter Design Direct-Form II Transpose Filter Filter Realization Wizard Time-Varying Direct-Form II Transpose Filter Time-Varying Lattice Filter Filtering: Multirate Filter Dyadic Analysis Filter Bank FIR Rate Conversion Dyadic Synthesis Filter Bank Wavelet
Block Library List Math Functions: Matrices and Linear Algebra Linear System Solvers Autocorrelation LPC Levinson-Durbin Cholesky Solver LU Solver Forward Substitution QR Solver LDL Solver SVD Solver Math Functions: Matrices and Linear Algebra Matrix Factorizations Cholesky Factorization QR Factorization LDL Factorization Singular Value Decomposition LU Factorization Math Functions: Matrices and Linear Algebra Matrix Inverses Cholesky Inverse LU Inverse LDL Inverse Pseudoinverse 5-13
5 DSP Block Reference Math Functions: Matrices and Linear Algebra Matrix Operations Constant Diagonal Matrix Matrix Scaling Create Diagonal Matrix Matrix Square Extract Diagonal Matrix Sum Extract Triangular Matrix Permute Matrix Identity Matrix Reciprocal Condition Matrix Concatenation (Simulink block) Submatrix Matrix 1-Norm Toeplitz Matrix Multiply Transpose Matrix Product Math Functions: Math Operations Complex Exponential dB Gain Cumulative Sum Normalization dB Conversion Diff
Block Library List Quantizers Quantizer (Simulink block) Uniform Encoder Uniform Decoder Signal Management: Buffers Buffer Stack Delay Line Triggered Delay Line Queue Unbuffer Signal Management: Indexing Flip Submatrix Multiport Selector Variable Selector Selector (Simulink block) Signal Management: Signal Attributes Check Signal Attributes Convert 2-D to 1-D Contiguous Copy Frame Status Conversion Convert 1-D to 2-D Inherit Complexity 5-15
5 DSP Block Reference Signal Management: Switches and Counters Counter Multiphase Clock Edge Detector N-Sample Enable Event-Count Comparator N-Sample Switch Signal Operations Convolution Unwrap Downsample Upsample Integer Delay Variable Fractional Delay Pad Variable Integer Delay Repeat Window Function Sample and Hold Zero Pad Statistics 5-16 Autocorrelation Median Correlation Minimum Detrend RMS Histogram Sort Maximum Standard Deviation Mean Variance
Block Library List Transforms Analytic Signal IDCT Complex Cepstrum IFFT DCT Real Cepstrum FFT 5-17
Analog Filter Design Purpose 5Analog Filter Design Library Filtering / Filter Designs Description The Analog Filter Design block designs and implements a Butterworth, Chebyshev type I, Chebyshev type II, or elliptic filter in a highpass, lowpass, bandpass, or bandstop configuration. Design and implement an analog filter. The input must be a sample-based scalar signal. The design and band configuration of the filter are selected from the Design method and Filter type pop-up menus in the dialog box.
Analog Filter Design attenuation Rs. Frequency values are in rad/s, and ripple and attenuation values are in dB.
Analog Filter Design Filter type The type of filter to design: Lowpass, Highpass, Bandpass, or Bandstop. Tunable. Filter order The order of the filter, for lowpass and highpass configurations. For bandpass and bandstop configurations, the order of the final filter is twice this value. Passband edge frequency The passband edge frequency, in rad/s, for the highpass and lowpass configurations of the Butterworth, Chebyshev type I, and elliptic designs.
Analog Filter Design References Antoniou, A. Digital Filters: Analysis, Design, and Applications. 2nd ed. New York, NY: McGraw-Hill, 1993.
Analytic Signal Purpose 5Analytic Signal Library Transforms Description The Analytic Signal block computes the complex analytic signal corresponding to each channel of the real M-by-N input, u. Compute the analytic signal of a discrete-time input. y = u + jH { u } where j = – 1 and H{⋅} denotes the Hilbert transform. The real part of the output in each channel is a replica of the real input in that channel; the imaginary part is the Hilbert transform of the input.
Analytic Signal Filter order The length of the FIR filter used to compute the Hilbert transform.
Autocorrelation Purpose 5Autocorrelation Library Statistics Description The Autocorrelation block computes the autocorrelation of each column (channel) in an M-by-N input matrix u. Matrix inputs must be frame-based. The result, y, is a frame-based (l+1)-by-N matrix whose jth column has elements Compute the autocorrelation of a vector input. M ∑ u*k, j u( k + i – 1 ), j y i, j = 1 ≤ i ≤ (l + 1) k=1 where ∗ denotes the complex conjugate, and l represents the maximum lag.
Autocorrelation Dialog Box All positive lags When selected, computes the autocorrelation over all M+1 positive lags. Maximum positive lag The maximum positive lag, l, for the autocorrelation. This parameter is enabled when the All positive lags check box is unselected. Scaling The type of scaling for the autocorrelation: None, Biased, Unbiased, or Unity at zero-lag. Tunable, except in Simulink’s external mode.
Autocorrelation LPC Purpose 5Autocorrelation LPC Library Estimation / Linear Prediction Description The Autocorrelation LPC block determines the coefficients of an N-step forward linear predictor for the time-series in length-M input vector, u, by minimizing the prediction error in the least-squares sense. A linear predictor is an FIR filter that predicts the next value in a sequence from the present and past inputs.
Autocorrelation LPC Algorithm The Autocorrelation LPC block computes the least-squares solution to min n Uã – b ã ∈ ℜ where ⋅ indicates the 2-norm and u1 0 L 0 u2 u1 O M M u2 O 0 u2 M O u1 U = M M M u2 , M M M M uM M M M 0 O M M M O O M 0 L 0 uM u3 M a2 ã = M an + 1 , M b = u M 0 M 0 Solving the least-squares problem via the normal equations * * U Uã = U b leads to the system of equations r 1 r *2 L r *n r2 r1 O M a2 a3 M M O O r *2 a rn L r2 r1 n + 1 –r2 = –r3 M –rn + 1 where r = [r
Autocorrelation LPC Note that the solution to the LPC problem is very closely related to the Yule-Walker AR method of spectral estimation. In that context, the normal equations above are referred to as the Yule-Walker AR equations. Dialog Box Output(s) The type of prediction coefficients output by the block. The block can output polynomial coefficients (A), reflection coefficients (K), or both (A and K).
Autocorrelation LPC Proakis, J. and D. Manolakis. Digital Signal Processing. 3rd ed. Englewood Cliffs, NJ: Prentice-Hall, 1996.
Backward Substitution Purpose 5Backward Substitution Library Math Functions / Matrices and Linear Algebra / Linear System Solvers Description The Backward Substitution block solves the linear system UX=B by simple backward substitution of variables, where U is the upper triangular M-by-M matrix input to the U port, and B is the M-by-N matrix input to the B port. The output is the solution of the equations, the M-by-N matrix X, and is always sample-based.
Backward Substitution See “Solving Linear Systems” on page 4-16 for related information.
Biquadratic Filter Purpose 5Biquadratic Filter Library Filtering / Filter Designs Description The Biquadratic Filter block applies a cascade of biquadratic filters independently to each input channel. Biquadratic filters are useful for reduced precision implementations because the coefficients are bounded between ±2 for typical minimum-phase designs. This may reduce scaling and coefficient sensitivity problems. Apply a cascade of biquadratic (second-order section) filters to the input.
Biquadratic Filter The SOS matrix parameter specifies the filter coefficients as a second-order section matrix of the type produced by the ss2sos and tf2sos functions in the Signal Processing Toolbox. b 11 b 21 b 31 a 11 a 21 a 31 b 12 b 22 b 32 a 12 a 22 a 32 M M M M M M b 1L b 2L b 3L a 1L a 2L a 3L a 11 = a 12 = … = a 1L = 1 This is an L-by-6 matrix whose rows contain the numerator and denominator coefficients bik and aik of each second-order section in H(z).
Biquadratic Filter H1 ( z ) ch1 ch2 chN ch1 ch2 chN ch1 ch2 chN ch1 ch2 chN ch1 ch2 chN ch1 ch2 chN v 11 v 11 L v 11 v 21 v 21 L v 21 H2 ( z ) v 12 v 12 L v 12 v 22 v 22 L v 22 M M O M HL ( z ) v 1L v 1L L v 1L v 2L v 2L L v 2L Each pair of elements in a column specifies v1k and v2k for second-order section k of the corresponding channel. Dialog Box SOS matrix The second-order section matrix specifying the filter’s coefficients.
Biquadratic Filter See Also Direct-Form II Transpose Filter Filter Realization Wizard Time-Varying Direct-Form II Transpose Filter filter sosfilt ss2sos tf2sos DSP Blockset DSP Blockset DSP Blockset MATLAB Signal Processing Toolbox Signal Processing Toolbox Signal Processing Toolbox See “Designing Filters with Various Filter Structures” on page 4-6 for related information.
Buffer Purpose 5Buffer Library Signal Management / Buffers Description The Buffer block redistributes the input samples to a new frame size, larger or smaller than the input frame size. Buffering to a larger frame size yields an output with a slower frame rate than the input, as illustrated below for scalar input. Buffer the input sequence to a smaller or larger frame size.
Buffer Mo=1, the input is simply passed through to the output, and retains the same dimension. Sample-based full-dimension matrix inputs are not accepted. The Buffer overlap parameter, L, specifies the number of samples (rows) from the current output to repeat in the next output, where L < Mo. For 0 ≤ L < Mo, the number of new input samples that the block acquires before propagating the buffered data to the output is the difference between the Output buffer size and Buffer overlap, Mo-L.
Buffer You can use the rebuffer_delay function with a frame size of 1 to precisely compute the delay (in samples) for sample-based signals. For the above example, d = rebuffer_delay(1,3,1) d = 4 This agrees with the four samples of delay (zeros) per channel shown in the figure above. Frame-Based Operation In frame-based operation, the Buffer block redistributes the samples in the input frame to an output frame with a new size and rate.
first input Input frame period = 4∗Tsi ch1 ch2 (Mo=3, L=1) ch1 ch2 t=0 ch1 ch2 1 1 0 0 ch1 ch2 t=4 1 2 3 4 ch1 ch2 1 1 0 0 ch1 ch2 5 6 7 8 ch1 ch2 ch1 ch2 Buffer 51 61 70 30 40 51 11 21 30 00 00 11 00 00 00 00 00 00 t=10 t=8 t=6 t=4 t=2 t=0 first output Output frame period = (M o-L)∗Tsi Note that the sequence is delayed by eight samples, which is the latency of the block in Simulink’s multitasking mode for the parameter settings of this example (see “Latency” below).
Buffer Nonzero Latency Sample-Based Operation.
Buffer See “Excess Algorithmic Delay (Tasking Latency)” on page 3-91 and “The Simulation Parameters Dialog Box” in the Simulink documentation for more information about block rates and Simulink’s tasking modes. Dialog Box Output buffer size The number of consecutive samples, Mo, from each channel to buffer into the output frame. Buffer overlap The number of samples, L, by which consecutive output frames overlap.
Buffer See Also Delay Line Unbuffer rebuffer_delay DSP Blockset DSP Blockset DSP Blockset See “Buffering Sample-Based and Frame-Based Signals” on page 3-47 for related information.
Burg AR Estimator Purpose 5Burg AR Estimator Library Estimation / Parametric Estimation Description The Burg AR Estimator block uses the Burg method to fit an autoregressive (AR) model to the input data by minimizing (least squares) the forward and backward prediction errors while constraining the AR parameters to satisfy the Levinson-Durbin recursion. Compute an estimate of AR model parameters using the Burg method.
Burg AR Estimator Dialog Box Output(s) The realization to output, model coefficients, reflection coefficients, or both. Inherit estimation order from input dimensions When selected, sets the estimation order p to one less than the length of the input vector. Estimation order The order of the AR model, p. This parameter is enabled when Inherit estimation order from input dimensions is not selected. References Kay, S. M. Modern Spectral Estimation: Theory and Application.
Burg Method Purpose 5Burg Method Library Estimation / Power Spectrum Estimation Description The Burg Method block estimates the power spectral density (PSD) of the input frame using the Burg method. This method fits an autoregressive (AR) model to the signal by minimizing (least-squares) the forward and backward prediction errors while constraining the AR parameters to satisfy the Levinson-Durbin recursion. Compute a parametric spectral estimate using the Burg method.
Burg Method Characteristics Advantages Burg Covariance Modified Covariance Yule-Walker Does not apply window to data Does not apply window to data Does not apply window to data Applies window to data Minimizes the forward and backward prediction errors in the least-squares sense, with the AR coefficients constrained to satisfy the L-D recursion Minimizes the forward prediction error in the least-squares sense Minimizes the forward and backward prediction errors in the least-squares sense Minim
Burg Method Examples The dspsacomp demo compares the Burg method with several other spectral estimation methods. Dialog Box Inherit estimation order from input dimensions When selected, sets the estimation order to one less than the length of the input vector. Tunable. Estimation order The order of the AR model. This parameter is enabled when Inherit estimation order from input dimensions is not selected.
Burg Method Supported Data Types Double-precision floating point See Also Burg AR Estimator Covariance Method Modified Covariance Method Short-Time FFT Yule-Walker Method pburg DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset Signal Processing Toolbox See “Power Spectrum Estimation” on page 4-15 for related information.
Check Signal Attributes Purpose 5Check Signal Attributes Library Signal Management / Signal Attributes Description The Check Signal Attributes block terminates the simulation with an error when the input characteristics differ from those specified by the block parameters. Generate an error when the input signal does or does not match selected attributes exactly.
Check Signal Attributes • Dimensionality Checks the dimension of signal for compliance (Is...) or noncompliance (Is not...) with the attributes in the subordinate Dimension menu, which are shown in the table below. See“Signal Dimension Nomenclature” on page 1-10 for a description of Simulink signal dimensions. M and N are positive integers unless otherwise indicated below.
Check Signal Attributes Dimensions Is... Is not...
Check Signal Attributes Dimensions (Continued) Is... Is not...
Check Signal Attributes column below can be individually selected from the subordinate Specific data type menu. General data type Is... Is not...
Check Signal Attributes Dialog Box Error if input Specifies whether the block generates an error when the input possesses none of the required attributes (Does not match attributes exactly), or when the input possesses all of the required attributes (Matches attributes exactly). Complexity The complexity for which the input should be checked, Real or Complex. Frame status The frame status for which the input should be checked, Sample-based or Frame-based.
Check Signal Attributes Data type Specifies whether the input should be checked for compliance (Is...) or noncompliance (Is not...) with the attributes in the subordinate General data type menu. General data type The general data type for which the input should be checked. This parameter is available when Is... or Is not... is selected in the Data type menu, and enables the subordinate Specific data type parameter in most cases.
Chirp Purpose 5Chirp Library DSP Sources Description The Chirp block outputs a swept-frequency cosine (chirp) signal with unity amplitude and continuous phase. To specify the desired output chirp signal, you must define its instantaneous frequency function, also known as the output frequency sweep. The frequency sweep can be linear, quadratic, or logarithmic, and repeats once every Sweep time by default.
Chirp Setting the Output Frame Status Use Samples per frame parameter to set the block’s output frame status, as summarized in the table. The Sample time parameter sets the sample time of both sample- and frame-based outputs.
Chirp The following diagram illustrates the possible shapes of the frequency sweep that you can obtain by setting the Frequency sweep and Sweep mode parameters. Possible Shapes of the Output Instantaneous Frequency Sweep Quadratic and Logarithmic Sweeps (Logarithmic sweeps cannot be negative.) Swept Cosine and Linear Sweeps These diagrams apply only to quadratic sweeps.
Chirp on page 5-62). The following table describes the characteristics of unidirectional and bidirectional sweeps. Sweep mode Parameter Settings Sweep Characteristics Unidirectional • Lasts for one Sweep time, Tsw • Repeats once every Tsw • Lasts for twice the Sweep time, 2*Tsw Bidirectional • Repeats once every 2*Tsw • First half is identical to its unidirectional counterpart. • Second half is a mirror image of the first half. The following diagram illustrates a linear sweep in both sweep modes.
Chirp • Target frequency (Hertz), fi(tg) • Target time (seconds), tg The following table summarizes the sweep values at specific times for all Frequency sweep settings. For information on the formulas used to compute sweep values at other times, see “Block Computation Methods”.
Chirp examine the following table and the diagram in “Shaping the Frequency Sweep by Setting Frequency Sweep and Sweep Mode” on page 5-62.
Chirp the chirp output when the Frequency Sweep parameter is set to Linear, Quadratic, or Logarithmic.
Chirp Swept Cosine Instantaneous Output Frequency at the Target Time is not the Target Frequency. The swept cosine sweep value at the Target time is not necessarily the Target frequency. This is because the user-specified sweep is not the actual frequency sweep of the swept cosine output, as noted in “Output Computation Method for Swept Cosine Frequency Sweep” on page 5-67. See Table 5-1, Instantaneous Frequency Sweep Values, for the actual value of the swept cosine sweep at the Target time.
Chirp Open the Example 1 model by clicking here in the MATLAB Help Browser. You can also rebuild the model yourself; see the following list for model parameter settings (leave unlisted parameters in their default states). Since Target time is set to equal Sweep time (1 second), the Target frequency (25 Hertz) is the final frequency of the unidirectional sweep.
Chirp specgram(dsp_examples_yout,[0:.
Chirp Open the Example 2 model by clicking here in the MATLAB Help Browser. 10 40 35 30 FREQUENCY AMPLITUDE 5 0 25 20 15 −5 10 5 −10 0 Frame: 6 1 2 3 TIME (s) 4 5 6 0 0 1 2 3 TIME (s) 4 5 Run your model to see the time domain output, and then type the following command to view the chirp output spectrogram. specgram(dsp_examples_yout,[0:.01:40],400,hamming(128),110) Example 3: When Sweep Time is Greater Than Target Time. Setting Sweep time to 1.
Chirp Open the Example 3 model by clicking here in the MATLAB Help Browser. 10 40 35 30 FREQUENCY AMPLITUDE 5 0 25 20 15 −5 10 5 −10 0 Frame: 6 1 2 3 TIME (s) 4 5 6 0 0 1 2 3 Time (s) 4 5 Run your model to see the time domain output, and then type the following command to view the chirp output spectrogram. specgram(dsp_examples_yout,[0:.01:40],400,hamming(128),110) Example 4: Output Sweep with Negative Frequencies. Modify the Example 1 model by changing Sweep time to 1.
Chirp Open the Example 4 model by clicking here in the MATLAB Help Browser. 30 10 25 FREQUENCY AMPLITUDE 5 0 20 15 10 −5 5 −10 0 Frame: 6 1 2 3 TIME (s) 4 5 6 0 0 1 2 3 TIME (s) 4 5 Run your model to see the time domain output, and then type the following command to view the chirp output spectrogram. specgram(dsp_examples_yout,[0:.1:30],400,hamming(128),110); Example 5: Output Sweep with Frequencies Greater Than Half the Sampling Frequency.
Chirp Open the Example 5 model by clicking here in the MATLAB Help Browser. 10 200 180 160 140 FREQUENCY AMPLITUDE 5 0 120 100 80 60 −5 40 −10 20 0 Frame: 6 1 2 3 TIME (s) 4 5 6 0 0 1 2 3 TIME (s) 4 5 Run your model to see the time domain output, and then type the following command to view the chirp output spectrogram.
Chirp Dialog Box Frequency sweep The type of output instantaneous frequency sweep, fi(t): Linear, Logarithmic, Quadratic, or Swept cosine. Tunable. Sweep mode The directionality of the chirp signal: Unidirectional or Bidirectional. Tunable. Initial frequency (Hz) For Linear, Quadratic, and Swept cosine sweeps, the initial frequency, f0, of the output chirp signal. For Logarithmic sweeps, Initial frequency is one less than the actual initial frequency of the sweep.
Chirp Target frequency (Hz) For Linear, Quadratic, and Logarithmic sweeps, the instantaneous frequency, fi(tg), of the output at the Target time, tg. For a Swept cosine sweep, Target frequency is the instantaneous frequency of the output at half the Target time, tg/2. When Frequency sweep is Logarithmic, you must set the Target frequency to be greater than the Initial frequency. Tunable.
Chirp See “Creating Signals Using Signal Generator Blocks” on page 3-36 for related information.
Cholesky Factorization Purpose 5Cholesky Factorization Library Math Functions / Matrices and Linear Algebra / Matrix Factorizations Description The Cholesky Factorization block uniquely factors the square Hermitian positive definite input matrix S as Factor a square Hermitian positive definite matrix into triangular components. S = LL * where L is a lower triangular square matrix with positive diagonal elements and L* is the Hermitian (complex conjugate) transpose of L.
Cholesky Factorization • Warning – Display a warning message in the MATLAB command window, and continue the simulation. The output is not a valid factorization. A partial factorization will be present in the upper left corner of the output. • Error – Display an error dialog box and terminate the simulation. Dialog Box Non-positive definite input Response to non-positive definite matrix inputs. Tunable. References Golub, G. H., and C. F. Van Loan. Matrix Computations. 3rd ed.
Cholesky Inverse Purpose 5Cholesky Inverse Library Math Functions / Matrices and Linear Algebra / Matrix Inverses Description The Cholesky Inverse block computes the inverse of the Hermitian positive definite input matrix S by performing Cholesky factorization. Compute the inverse of a Hermitian positive definite matrix using Cholesky factorization. S –1 * –1 = ( LL ) L is a lower triangular square matrix with positive diagonal elements and L* is the Hermitian (complex conjugate) transpose of L.
Cholesky Inverse References Golub, G. H., and C. F. Van Loan. Matrix Computations. 3rd ed. Baltimore, MD: Johns Hopkins University Press, 1996. Supported Data Types Double-precision floating point See Also Cholesky Factorization Cholesky Solver LDL Inverse LU Inverse Pseudoinverse inv DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset MATLAB See “Inverting Matrices” on page 4-19 for related information.
Cholesky Solver Purpose Solve the equation SX=B for X when S is a square Hermitian positive definite matrix. Library Math Functions / Matrices and Linear Algebra / Linear System Solvers Description The Cholesky Solver block solves the linear system SX=B by applying Cholesky factorization to input matrix at the S port, which must be square (M-by-M) and Hermitian positive definite.
Cholesky Solver LY = B * L X = Y Dialog Box Non-positive definite input Response to non-positive definite matrix inputs. Tunable. Supported Data Types Double-precision floating point See Also Autocorrelation LPC Cholesky Factorization Cholesky Inverse LDL Solver LU Solver QR Solver chol DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset MATLAB See “Solving Linear Systems” on page 4-16 for related information.
Complex Cepstrum Purpose 5Complex Cepstrum Library Transforms Description The Complex Cepstrum block computes the complex cepstrum of each channel in the real-valued M-by-N input matrix, u. For both sample-based and frame-based inputs, the block assumes that each input column is a frame containing M consecutive samples from an independent channel. The block does not accept complex-valued inputs. Compute the complex cepstrum of an input.
Complex Cepstrum Inherit FFT length from input port dimensions When selected, matches the output frame size to the input frame size. FFT length The number of frequency points at which to compute the FFT, which is also the output frame size, Mo. This parameter is available when Inherit FFT length from input port dimensions is not selected.
Complex Exponential Purpose 5Complex Exponential Library Math Functions / Math Operations Description The Complex Exponential block computes the complex exponential function for each element of the real input, u. Compute the complex exponential function. y = e ju where j = the input. = cos u + j sin u – 1 .
Constant Diagonal Matrix Purpose 5Constant Diagonal Matrix Library DSP Sources, Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Constant Diagonal Matrix block outputs a square diagonal matrix constant. The Constant along diagonal parameter determines the values along the matrix diagonal. This parameter can be a scalar to be repeated for all elements along the diagonal, or a vector containing the values of the diagonal elements.
Constant Diagonal Matrix Supported Data Types (MATLAB commands for casting values to certain data types are provided in ( parentheses.
Constant Ramp Purpose 5Constant Ramp Library DSP Sources Description The Constant Ramp block generates the constant ramp signal Generate a ramp signal with length based on input dimensions. y = (0:L-1)*m + b where m is the slope specified by the scalar Slope parameter, b is the y-intercept specified by the scalar Offset parameter.
Constant Ramp See Also Create Diagonal Matrix Identity Matrix DSP Constant DSP Blockset DSP Blockset DSP Blockset See “Creating Signals Using Constant Blocks” on page 3-33 for related information.
Contiguous Copy Purpose 5Contiguous Copy Library Signal Management / Signal Attributes Description The Contiguous Copy block copies the input to a contiguous block of memory, and passes this new copy to the output. The output is identical to the input, but is guaranteed to reside in a contiguous section of memory. Create a discontiguous input in a contiguous block of memory (for RTW code generation from blocks linked to versions of the DSP Blockset prior to 4.0).
Contiguous Copy Original memory allocation m1 m2 m3 m4 m5 m6 m7 m8 Memory addresses m9 m10 m11 u1 u2 u3 u4 u5 u6 u7 u8 Memory contents u6 u3 u7 m6 m9 m3 m 10 m7 m 11 Vector of pointers to discontiguous memory Dialog Box Supported Data Types 5-92 New memory allocation Fixed-point Custom data types Boolean 8-, 16-, and 32-bit signed integer 8-, 16-, and 32-bit unsigned integer Single-precision floating point Double-precision floating point Vector of pointers to new contiguous memory v3.
Convert 1-D to 2-D Purpose 5Convert 1-D to 2-D Library Signal Management / Signal Attributes Description The Convert 1-D to 2-D block reshapes a length-Mi 1-D vector or an Mi-by-Ni matrix to an Mo-by-No matrix, where Mo is specified by the Number of output rows parameter, and No is specified by the Number of output columns parameter. Reshape a 1-D or 2-D input to a 2-D matrix with the specified dimensions.
Convert 1-D to 2-D Number of output rows The number of rows, Mo, in the output matrix. Tunable. Number of output columns The number of rows, No, in the output matrix. Tunable. Frame-based output Creates a frame-based output when selected. Tunable.
Convert 2-D to 1-D Purpose 5Convert 2-D to 1-D Library Signal Management / Signal Attributes Description The Convert 2-D to 1-D block reshapes an M-by-N matrix input to a 1-D vector with length M∗N. Convert a 2-D matrix input to a 1-D vector. y = u(:) % Equivalent MATLAB code The input is reshaped columnwise, as shown below for a 3-by-2 matrix. u1 u4 u2 u5 (u1 u2 u3 u4 u5 u6) u3 u6 The output is always sample-based.
Convert Complex DSP To Simulink Purpose 5Convert Complex DSP To Simulink Library Elementary Functions, in Math Functions Description The Convert Complex DSP To Simulink block accepts complex data (scalar, vector, matrix) in the DSP Blockset Version 2.2 format, and outputs the same data in the Simulink Version 3 complex format. Only complex data should be supplied to this block. Convert complex data from the DSP Blockset Version 2.2 format to the Simulink Version 3 format.
Convert Complex DSP To Simulink Existing (Version 2.2) complex-data Subsystem B upgraded to Version 3.0 complex-data (Subsystem A remains a Version 2.2 implementation) Subsystem A upgraded to Version 3.0 complex-data (Subsystem B remains a Version 2.
Convert Complex Simulink To DSP Purpose 5Convert Complex Simulink To DSP Library Elementary Functions, in Math Functions Description The Convert Complex Simulink To DSP block accepts complex data (scalar, vector, matrix) in the Simulink Version 3 format, and outputs the same data in the DSP Blockset Version 2.2 complex format. Only complex data should be supplied to this block. Convert complex data from the Simulink Version 3 format to the DSP Blockset Version 2.2 format.
Convert Complex Simulink To DSP Existing (Version 2.2) complex-data Subsystem B upgraded to Version 3.0 complex-data (Subsystem A remains a Version 2.2 implementation) Subsystem A upgraded to Version 3.0 complex-data (Subsystem B remains a Version 2.
Convolution Purpose 5Convolution Library Signal Operations Description The Convolution block convolves corresponding columns (channels) of Mu-by-N input matrix u and Mv-by-N input matrix v. Compute the convolution of two inputs. Frame-Based Inputs Matrix inputs must be frame-based. The output, y, is a frame-based (Mu+Mv-1)-by-N matrix whose jth column has elements max ( M u, M v ) y i, j = ∑ u k, j v *( i – k + 1 ), j 1 ≤ i ≤ ( Mu + Mv – 1 ) k=1 where ∗ denotes the complex conjugate.
Convolution The dimensions of the sample-based output vector are determined by the dimensions of the input vectors: • When both inputs are row vectors, or when one input is a row vector and the other is a 1-D vector, the output is a 1-by-(Mu+Mv-1) row vector. • When both inputs are column vectors, or when one input is a column vector and the other is a 1-D vector, the output is a (Mu+Mv-1)-by-1 column vector. • When both inputs are 1-D vectors, the output is a 1-D vector of length Mu+Mv-1.
Correlation Purpose 5Correlation Library Statistics Description The Correlation block computes the cross-correlation of corresponding columns (channels) of the Mu-by-N input matrix u and Mv-by-N input matrix v. The frame status of both inputs must be the same. The block does not accept sample-based full-dimension matrix inputs or 2-D row vector inputs. Compute the correlation along the columns of two inputs. Frame-Based Inputs Matrix inputs must be frame-based.
Correlation max ( M u, M v ) yi = ∑ u k v *( k – i + M v ) 1 ≤ i ≤ ( Mu + Mv – 1 ) k=1 The dimensions of the sample-based output vector are determined by the dimensions of the input vectors: • When both inputs are column vectors, or when one input is a column vector and the other is a 1-D vector, the output is a (Mu+Mv-1)-by-1 column vector. • When both inputs are 1-D vectors, the output is a 1-D vector of length Mu+Mv-1.
Counter Purpose 5Counter Library Signal Management / Switches and Counters Description The Counter block increments or decrements an internal counter each time it receives a trigger event at the Clk port. A trigger event at the Rst port resets the counter to its initial state. Count up or down through a specified range of numbers. The input to the Rst port must be a real sample-based scalar. The input to the Clk port can be a real sample-based scalar, or a real frame-based vector (i.e.
Counter • 16 bits specifies a counter with a range of 0 to 65535. • 32 bits specifies a counter with a range of 0 to 232-1. • User defined enables the supplementary Maximum count parameter, which allows you to specify an arbitrary integer as the upper count limit. The range of the counter is then 0 to the Maximum count value. Sample-Based Operation The block operates in sample-based mode when the Clk input is a sample-based scalar. Sample-based vectors and matrices are not accepted.
Counter parameter setting. When the counter value does equal the Hit value setting, the block generates a value of 1 at the Hit port. The output is sample-based with the same sample period as the inputs. • Count and Hit configures the block icon with both ports. Frame-Based Operation The block operates in frame-based mode when the Clk input is a frame-based vector (i.e., single channel). Multichannel frame-based inputs are not accepted.
Counter To run the model, first select Simulation Parameters from the Simulation menu, and set the Stop time to 30. Then adjust the block parameters as described below. (Use the default settings for the Pulse Generator and To Workspace blocks.
Clk Rst [1] [0] [0] [0] [5] [1] [0] [4] [0] [0] [4] [1] [1] [0] [3] [0] [0] [0] [3] [1] [1] [0] [1] [4] [1] [1] [1] [3] [0] [0] [1] [3] [0] [1] [1] [2] [0] [0] [1] [2] [0] [1] [1] [1] [0] [0] [1] [1] [0] [1] [1] [0] [0] [0] [1] [0] [0] [1] [1] [20] [0] [0] [1] [20] [0] [1] [1] [19] [0] [0] [1] [19] [0] [1] [1] [18] [0] [0] [1] [18] [0] ... ... ... ...
Counter Dialog Box Count direction The counter direction, Up or Down. Tunable, except in Simulink’s external mode. Count event The type of event that triggers the block to increment, decrement, or reset the counter when received at the Clk or Rst ports. Free running disables the Clk port, and counts continuously with the period specified by the Sample time parameter. Counter size The range of integer values the block should count through before recycling to zero.
Counter Initial count The counter’s initial value at the start of the simulation and after reset. Tunable, except in Simulink’s external mode. Output Selects the output port(s) to enable: Cnt, Hit, or both. Hit value The scalar value whose occurrence in the count should be flagged by a 1 at the (optional) Hit output. This parameter is available when Hit or Count and Hit are selected in the Output menu. Tunable, except in Simulink’s external mode. Reset input Enables the Rst input port when selected.
Covariance AR Estimator Purpose 5Covariance AR Estimator Library Estimation / Parametric Estimation Description The Covariance AR Estimator block uses the covariance method to fit an autoregressive (AR) model to the input data. This method minimizes the forward prediction error in the least-squares sense. Compute an estimate of AR model parameters using the covariance method.
Covariance AR Estimator References Kay, S. M. Modern Spectral Estimation: Theory and Application. Englewood Cliffs, NJ: Prentice-Hall, 1988. Marple, S. L., Jr., Digital Spectral Analysis with Applications. Englewood Cliffs, NJ: Prentice-Hall, 1987.
Covariance Method Purpose 5Covariance Method Library Estimation / Power Spectrum Estimation Description The Covariance Method block estimates the power spectral density (PSD) of the input using the covariance method. This method fits an autoregressive (AR) model to the signal by minimizing the forward prediction error in the least-squares sense.
Covariance Method Inherit FFT length from input dimensions When selected, uses the input frame size as the number of data points, Nfft, on which to perform the FFT. Tunable. FFT length The number of data points, Nfft, on which to perform the FFT. If Nfft exceeds the input frame size, the frame is zero-padded as needed. This parameter is enabled when Inherit FFT length from input dimensions is not selected. References Kay, S. M. Modern Spectral Estimation: Theory and Application.
Create Diagonal Matrix Purpose 5Create Diagonal Matrix Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Create Diagonal Matrix block populates the diagonal of the M-by-M matrix output with the elements contained in the length-M vector input, D. The elements off the diagonal are zero. Create a square diagonal matrix from diagonal elements. A = diag(D) Equivalent MATLAB code The output is always sample-based.
Cumulative Sum Purpose 5Cumulative Sum Library Math Functions / Math Operations Description The Cumulative Sum block computes the cumulative sum of the row or column elements in the M-by-N input matrix u. Compute the cumulative sum of row or column elements. Columnwise Summing When the Cumulative Sum along parameter is set to Columns, the block computes the cumulative sum of the column elements.
Cumulative Sum j y i, j = ∑ u i, k 1≤j≤N k=1 The frame status of the output is the same as the input. For both sample-based and frame-based inputs, the first column of each successive output is the same as that of the corresponding input. For convenience, length-N 1-D vector inputs are treated as 1-by-N row vectors for row-wise summation, and the output is a length-N 1-D vector. Dialog Box Cumulative Sum along The dimension along which to compute the cumulative summations.
dB Conversion Purpose 5dB Conversion Library Math Functions / Math Operations Description The dB Conversion block converts a linearly scaled power or amplitude input to dB or dBm. The Input signal parameter specifies whether the input is a power signal or a voltage signal, and the Convert to parameter controls the scaling of the output. When selected, the Add eps to input to protect against “log(0) = -inf” parameter adds a value of eps to all power and voltage inputs.
dB Conversion The dBm conversion is equivalent to performing the dB operation after converting the (abs(u)^2/R) result to milliwatts. Dialog Box Convert to The logarithmic scaling to which the input is converted, dB or dBm. Tunable. Input signal The type of input signal, Power or Amplitude. Tunable. Load resistance The scale factor used to convert voltage inputs to units of power. Tunable. Add eps to input to protect against “log(0) = -inf” When selected, adds eps to all input values (power or voltage).
dB Gain Purpose 5dB Gain Library Math Functions / Math Operations Description The dB Gain block multiplies the input by the decibel values specified in the Gain parameter. For an M-by-N input matrix u with elements uij, the Gain parameter can be a real M-by-N matrix with elements gij to be multiplied element-wise with the input, or a real scalar. Apply a gain specified in decibels.
dB Gain Supported Data Types Single-precision floating point Double-precision floating point See Also dB Conversion Math Function log10 DSP Blockset Simulink MATLAB 5-121
DCT Purpose 5DCT Library Transforms Description The DCT block computes the unitary discrete cosine transform (DCT) of each channel in the M-by-N input matrix, u. Compute the DCT of the input. y = dct(u) % Equivalent MATLAB code For both sample-based and frame-based inputs, the block assumes that each input column is a frame containing M consecutive samples from an independent channel. The frame size, M, must be a power of two.
DCT Dialog Box Supported Data Types Double-precision floating point See Also Complex Cepstrum FFT IDCT Real Cepstrum dct DSP Blockset DSP Blockset DSP Blockset DSP Blockset Signal Processing Toolbox 5-123
Delay Line Purpose 5Delay Line Library Signal Management / Buffers Description The Delay Line block buffers the input samples into a sequence of overlapping or underlapping matrix outputs. In the most typical use (sample-based inputs), each output differs from the preceding output by only one sample, as illustrated below for scalar input. Rebuffer a sequence of inputs with a one-sample shift.
Delay Line In the model below, the block operates on a sample-based input with a Delay line size of 3.
Delay Line When Mo = Mi, the output data is identical to the input data, but is delayed by the latency of the block. Due to the block’s latency, the outputs are always delayed by one frame, the entries of which are specified by the Initial conditions (see “Initial Conditions” below). The output frame period is equal to the input frame period (Tfo=Tfi).
Delay Line Dialog Box Delay line size The number of rows in output matrix, Mo. Initial conditions The value of the block’s initial output, a scalar, vector, or matrix.
Detrend Purpose 5Detrend Library Statistics Description The Detrend block removes a linear trend from the length-M input vector, u, by subtracting the straight line that best fits the data in the least-squares sense. Remove a linear trend from a vector. The least-squares line, û = ax + b, is the line with parameters a and b that minimizes the quantity M ∑ ( ui – ûi ) 2 i=1 for M evenly-spaced values of x, where ui is the ith element in the input vector.
Difference Purpose 5Difference Library Math Functions / Math Operations Description The Difference block computes the difference between adjacent elements in rows or columns of the M-by-N input matrix u. Compute the element-to-element difference along rows or columns. Columnwise Differencing When the Difference along parameter is set to Columns, the block computes differences between adjacent column elements.
Difference The output is an M-by-(N-1) matrix whose ith row has elements y i, j = u i, j + 1 – u i, j 1 ≤ j ≤ (N – 1) The frame status of the output is the same as the input. For convenience, length-N 1-D vector inputs are treated as 1-by-N row vectors for rowwise differencing, and the output is 1-D. Dialog Box Difference along The dimension along which to compute element-to-element differences. Columns specifies columnwise differencing, while Rows specifies rowwise differencing. Tunable.
Digital Filter Design Purpose 5Digital Filter Design Library Filtering / Filter Designs Description The Digital Filter Design block implements a digital FIR or IIR filter that you design using the Filter Design and Analysis Tool graphical user interface, referred to as FDATool. The block applies the filter to a discrete-time input signal and outputs the resulting signal. Design and implement a variety of digital FIR and IIR filters.
Digital Filter Design Dialog Box Double-click the block to open FDATool.
Digital Filter Design See Also Analog Filter Design Window Function fdatool fvtool sptool DSP Blockset DSP Blockset Signal Processing Toolbox Signal Processing Toolbox Signal Processing Toolbox 5-133
Direct-Form II Transpose Filter Purpose 5Direct-Form II Transpose Filter Library Filtering / Filter Designs Description The Direct-Form II Transpose Filter block applies a transposed direct-form II IIR filter to the input. Apply an IIR filter to the input. ... u ( k) b( m ) Σ -a(n) zn-1(k) b(3) z-1 ... Σ -a(3) z 2 ( k) b(2) Σ z-1 -a(2) z1(k) b(1) z-1 Σ y( k) ... This is a canonical form that has the minimum number of delay elements. The filter order is max(m,n)-1.
Direct-Form II Transpose Filter Initial Conditions In its default form, the filter initializes the internal filter states to zero, which is equivalent to assuming past inputs and outputs are zero. The block also accepts optional nonzero initial conditions for the filter delays.
Direct-Form II Transpose Filter Dialog Box Numerator The filter numerator vector. Tunable; the numerator coefficients can be adjusted while the simulation runs, but the vector length (i.e., the filter order) must remain the same. Denominator The filter denominator vector. Tunable; the denominator coefficients can be adjusted while the simulation runs, but the vector length (i.e., the filter order) must remain the same. Initial conditions The filter’s initial conditions, a scalar, vector, or matrix.
Direct-Form II Transpose Filter See Also Biquadratic Filter Discrete Filter Filter Realization Wizard Time-Varying Direct-Form II Transpose Filter filter DSP Blockset Simulink DSP Blockset DSP Blockset MATLAB See “Designing Filters with Various Filter Structures” on page 4-6 for related information.
Discrete Impulse Purpose 5Discrete Impulse Library DSP Sources Description The Discrete Impulse block generates an impulse (the value 1) at output sample D+1, where D is specified by the Delay parameter (D ≥ 0). All output samples preceding and following sample D+1 are zero. Generate a discrete impulse. When D is a length-N vector, the block generates an M-by-N matrix output representing N distinct channels, where frame size M is specified by the Samples per frame parameter.
Discrete Impulse Run the model and look at the output, yout. The first few samples of each channel are shown below. yout(1:10,:) ans = 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 The block generates an impulse at sample 1 of channel 1 (first column), at sample 4 of channel 2 (second column), and at sample 6 of channel 3 (third column). Dialog Box Delay The number of zero-valued output samples, D, preceding the impulse. A length-N vector specifies an N-channel output. Tunable.
Discrete Impulse Sample time The sample period, Ts, of the output signal. The output frame period is M∗Ts. Tunable. Samples per frame The number of samples, M, in each output frame. Tunable. Data type The precision of the output. Tunable.
Downsample Purpose 5Downsample Library Signal Operations Description The Downsample block resamples each channel of the Mi-by-N input at a rate K times lower than the input sample rate by discarding K-1 consecutive samples following each sample passed through to the output. The integer K is specified by the Downsample factor parameter. Resample an input at a lower rate by deleting samples.
Downsample • Enforce single rate When Enforce single rate is selected, the block forces the output sample rate to match the input sample rate (Tso = Tsi) by repeating every Kth input sample K times at the output. The block is therefore single-rate. (The block’s operation when Enforce single rate is selected is similar to the operation of a Sample and Hold block with a repeating trigger event of period KTsi.) The setting of the Frame-based mode popup menu does not affect sample-based inputs.
Downsample • Maintain input frame rate The block generates the output at the slower (downsampled) rate by using a proportionally smaller frame size than the input. For downsampling by a factor of K, the output frame size is K times smaller than the input frame size (Mo = Mi/K), but the input and output frame rates are equal. The model below shows a single-channel input of frame size 64 being downsampled by a factor of 4 to a frame size of 16. The input and output frame rates are identical.
Downsample Nonzero Latency. The Downsample block is multirate for most settings other than those in the above table. The amount of latency for multirate operation depends on input signal sampling and Simulink’s tasking mode, as shown in the table below. Multirate...
Downsample Adjust the block parameters as follows: • Configure the Signal From Workspace block to generate a two-channel signal with frame size of 4 and sample period of 0.25 seconds. This represents an output frame period of 1 second (0.25∗4). The first channel should contain the positive ramp signal 1, 2, ..., 100, and the second channel should contain the negative ramp signal -1, -2, ..., -100. The settings are: - Signal = [(1:100)' (-1:-1:-100)'] - Sample time = 0.
Downsample panel of the Simulation Parameters dialog box, and select MultiTasking from the Mode parameter. Additionally, set the Stop time to 30. Run the model and look at the output, yout. The first few samples of each channel are shown below.
Downsample Downsample factor The integer factor, K, by which to decrease the input sample rate. Sample offset The sample offset, D, which must be an integer in the range [0, K-1]. Initial condition The value with which the block is initialized for cases of nonzero latency; a scalar or matrix. Sample-based mode The method by which to implement downsampling for sample-based inputs: Allow multirate (i.e, decrease the output sample rate), or Force single-rate (i.e.
DSP Constant Purpose 5DSP Constant Library DSP Sources Description The DSP Constant block generates a signal whose value remains constant throughout the simulation. The Constant value parameter specifies the constant to output, and can be any valid MATLAB expression that evaluates to a scalar, vector, or matrix. Generate a discrete-time or continuous-time constant signal.
DSP Constant Dialog Box Constant value The constant to generate. Tunable; values entered here can be tuned, but their dimensions must remain fixed. Interpret vector parameters as 1-D When selected, generates 1-D vector outputs for Constant value settings with vector dimension; when unselected, generates 2-D vector outputs for Constant value settings with vector dimension. An active Interpret vector parameters as 1-D setting is overridden by an active Frame-based output setting.
DSP Constant Supported Data Types (MATLAB commands for casting values to certain data types are provided in parentheses.) Boolean (boolean) 8-, 16-, and 32-bit signed integer (int8, int16, int32) 8-, 16-, and 32-bit unsigned integer (uint8, uint16, uint32) Single-precision floating point (single) Double-precision floating point (double) See Also Constant Signal From Workspace Simulink DSP Blockset See “Creating Signals Using Constant Blocks” on page 3-33 for related information.
Dyadic Analysis Filter Bank Purpose 5Dyadic Analysis Filter Bank Library Filtering / Multirate Filters Description The Dyadic Analysis Filter Bank block decomposes a broadband signal into a collection of successively more bandlimited components by repeatedly dividing the frequency range. The typical (asymmetric) n-level filter bank structure is shown below. Decompose a signal into components of equal or logarithmically decreasing frequency intervals and sample rates.
Dyadic Analysis Filter Bank functions in the Wavelet Toolbox (see the Wavelet Toolbox documentation for more information). Tree Structure The Tree structure parameter specifies an asymmetric (or wavelet) tree, as shown above, or a symmetric structure, as shown below. Note that the symmetric structure decomposes both the high- and low-frequency subbands at each level, whereas the asymmetric structure only decomposes the low-frequency bands. Asymmetric Tree.
Dyadic Analysis Filter Bank The bottom two outputs (yn and yn+1) share the same sample period, bandwidth, and frame size because they originate at the same tree level. Symmetric Tree. The symmetric structure shown below (Tree structure set to Symmetric) has 2n outputs, where n is the Number of levels parameter value. Symmetric Filter Bank, n Levels HP HP ↓2 y1 LP ↓2 y2 HP ↓2 y3 LP ↓2 y4 HP ↓2 y5 LP ↓2 y6 HP ↓2 y7 LP ↓2 y2n ... ↓2 ↓2 HP LP ... ↓2 u HP ...
Dyadic Analysis Filter Bank In frame-based mode, the sample period of output yk is reflected by its frame size, Mo,k, rather than by its frame rate. Mi M o, k = ------n 2 n (1 ≤ k ≤ 2 ) Sample-Based Operation An M-by-N sample-based matrix input is treated as M∗N independent channels, and the block filters each channel independently over time. The output at each port is the same size as the input, one output channel for each input channel.
Dyadic Analysis Filter Bank Tso = 1/32) Tso = 1/16) Tfi = 1 Tsi = 1/64 Tso = 1/8) Tfo = 1 Tso = 1/8) Applications Wavelets. The primary application for dyadic analysis filter banks is coding for data compression using wavelets. At the transmitting end, the output of the dyadic analysis filter bank is fed to a lossy compression scheme, which typically assigns the number of bits for each filter bank output in proportion to the relative energy in that frequency band.
Dyadic Analysis Filter Bank Fs/16 Fs/8 Fs/4 Fs Fs/2 Fs/32 Fs/64 Fs/128 Fs/256 0 Latency Zero Latency. The Dyadic Analysis Filter Bank block has no tasking latency for frame-based operation, which is always single-rate. The block therefore analyzes the first input sample (received at t=0) to produce the first output sample at each port. Nonzero Latency. The Dyadic Analysis Filter Bank block has tasking latency only for sample-based operation, which is always multirate.
Dyadic Analysis Filter Bank Dialog Box Lowpass FIR filter coefficients A vector of filter coefficients (descending powers of z) to be shared by all the lowpass filters in the filter bank. Highpass FIR filter coefficients A vector of filter coefficients (descending powers of z) to be shared by all the highpass filters in the filter bank. Number of levels The number of filter bank levels. An n-level asymmetric structure has n+1 outputs; an n-level symmetric structure has 2n outputs.
Dyadic Analysis Filter Bank Supported Data Types Double-precision floating point (double) See Also Dyadic Synthesis Filter Bank Wavelet Analysis DSP Blockset DSP Blockset See the following sections for related information: • “Converting Sample Rates and Frame Rates” on page 3-20 • “Multirate Filters” on page 4-9 5-158
Dyadic Synthesis Filter Bank Purpose 5Dyadic Synthesis Filter Bank Library Filtering / Multirate Filters Description The Dyadic Synthesis Filter Bank block typically reconstructs a signal that was decomposed by the Dyadic Analysis Filter Bank block. The reconstruction or synthesis process is the inverse of the analysis process, and restores the original signal by upsampling, filtering, and summing the bandlimited inputs in stages corresponding to the analysis process.
Dyadic Synthesis Filter Bank highpass and lowpass direct-form II transpose filter in the filter bank. The values of these coefficients are typically computed together with the dyadic analysis coefficients using the wavelet family functions in the Wavelet Toolbox (see the Wavelet Toolbox documentation for more information). Tree Structure The Tree structure parameter specifies an asymmetric (or wavelet) tree, as shown above, or a symmetric structure, as shown below.
Dyadic Synthesis Filter Bank M i, n + 1 = M i, n Symmetric Tree. The symmetric structure shown below (Tree structure set to Symmetric) has 2n inputs, where n is the Number of levels parameter value. Symmetric Filter Bank, n Levels u1 ↑2 HP Σ u2 ↑2 LP u3 ↑2 HP ↑2 LP u4 u5 ↑2 ↑2 HP Σ Σ ... ↑2 ↑2 HP LP Σ y HP Σ u6 ↑2 LP u7 ↑2 HP ↑2 LP u2n ... ... ↑2 HP Σ Σ Tsi = (2n)Ts for all 2n inputs ...
Dyadic Synthesis Filter Bank The figure below shows the input and output sample periods for the four 64-channel sample-based inputs to a three-level filter bank. The fastest input has a period of 2, so the output period is 1. Tsi = 2 Tsi = 4 Tso = 1 Tsi = 8 Tsi = 8 Frame-Based Operation An Mi-by-N frame-based matrix input is treated as N independent channels, and the block filters each channel independently over time. The number of columns in the output is the same as the number of columns in the input.
Dyadic Synthesis Filter Bank Applications The primary application for asymmetric dyadic synthesis filter banks is coding for compression using wavelets. At the transmitting end, the output of a dyadic analysis filter bank is fed to a lossy compression scheme, which typically assigns the number of bits for each filter bank output in proportion to the relative energy in that frequency band.
Dyadic Synthesis Filter Bank asymmetric tree structure generates 2n-2 zero-valued output samples in each channel before propagating the first synthesized output sample (computed from the inputs received at t=0). See “Excess Algorithmic Delay (Tasking Latency)” in Chapter 3 and “The Simulation Parameters Dialog Box” in the Simulink documentation for more information about block rates and Simulink’s tasking modes.
Dyadic Synthesis Filter Bank Strang, G. and T. Nguyen. Wavelets and Filter Banks. Wellesley, MA: Wellesley-Cambridge Press, 1996. Vaidyanathan, P. P. Multirate Systems and Filter Banks. Englewood Cliffs, NJ: Prentice Hall, 1993.
Edge Detector Purpose 5Edge Detector Library Signal Management / Switches and Counters Description The Edge Detector block generates an impulse (the value 1) in a given output channel when the corresponding channel of the input transitions from zero to a nonzero value. Otherwise, the block generates zeros in each channel. Detect a transition of the input from zero to a nonzero value. The output has the same dimension and sample rate as the input.
Edge Detector Input ch1 Simulation time First input Output ch2 –5 0 –4 1 ch1 First output ch2 00 01 ch2 edge –3 0 –2 0 00 00 –1 2 0 0 01 00 1 0 2 0 10 00 ch1 edge 3 3 4 0 01 00 ch2 edge 5 0 0 0 00 00 ch2 edge Dialog Box Supported Data Types Double-precision floating point See Also Counter Event-Count Comparator DSP Blockset DSP Blockset 5-167
Event-Count Comparator Purpose 5Event-Count Comparator Library Signal Management / Switches and Counters Description The Event-Count Comparator block records the number of nonzero inputs to the Data port during the period that the block is enabled by a high signal (the value 1) at the interval (Int) port. Both inputs must be scalars, and the Int input must be sample-based. Detect threshold crossing of accumulated nonzero inputs.
Event-Count Comparator [0] [0] [1] [1] [2] [1] [2] [3] [1] [3] [4] [1] [4] [5] [1] [5] [1] [0] [0] [5] [1] [0] [0] [5] [1] [0] [1] [0] [0] [5] [1] [1] [0] [4] [1] [2] [0] [3] [1] [3] [2] [1] [4] [1] [1] [5] [1] [0] [0] [5] [1] ... ... ... Output Int ...
Extract Diagonal 5Extract Diagonal Purpose Extract the main diagonal of the input matrix. Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Extract Diagonal block populates the 1-D output vector with the elements on the main diagonal of the M-by-N input matrix A. D = diag(A) Equivalent MATLAB code The output vector has length min(M,N), and is always sample-based.
Extract Triangular Matrix Purpose 5Extract Triangular Matrix Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Extract Triangular Matrix block creates a triangular matrix output from the upper or lower triangular elements of an M-by-N input matrix. A length-M 1-D vector input is treated as an M-by-1 matrix. Extract the lower or upper triangle from an input matrix.
Extract Triangular Matrix Dialog Box Extract The component of the matrix to copy to the output, upper triangle or lower triangle. Tunable, except in Simulink’s external mode.
FFT Purpose 5FFT Library Transforms Description The FFT block computes the fast Fourier transform (FFT) of each channel in the M-by-N or length-M input, u, where M must be a power of two. To work with other input sizes, use the Zero Pad block to pad or truncate the length-M dimension to a power-of-two length. The output is always complex-valued and sample-based (it is unoriented 1-D vectors for unoriented inputs). Compute the FFT of the input.
FFT dimension to a power-of-two length. Also, to get valid outputs, your inputs must be in linear order. Valid Block Inputs Dimension Along Which Block Computes DFT Output port rate = input port rate Frame-based M-by-N matrix Column • Sample-based Sample-based M-by-N matrix, M ≠ 1 Column • Same dimensions as input Sample-based 1-by-M row vector Row • Each column (each row for sample-based row inputs) contains the M-point DFT of the corresponding input channel in linear or bit-reversed order.
FFT Click here in the MATLAB Help Browser to open a Simulink model based on the following diagram.
FFT Ordering Output Column Entries (Output in bit-reversed order Parameter) Set the Output in bit-reversed order parameter as follows to indicate the ordering of the output’s column elements. For a definition of bit-reversed ordering, see “Description of Bit-Reversed Ordering” on page 5-177. Parameter Setting Ordering of Output Channel Elements Output Column Entries Linear order (See the following note.) kth column element is the DFT of the corresponding input column at the kth frequency.
FFT Description of Bit-Reversed Ordering. Two numbers are bit-reversed values of each other when the binary representation of one is the mirror image of the binary representation of the other. For example, in a three-bit system, one and four are bit-reversed values of each other, since the three-bit binary representation of one, 001, is the mirror image of the three-bit binary representation of four, 100. The sequence 0, 1, 2, 3, 4, 5, 6, 7, is in linear order.
FFT e –j 2π ( m – 1 ) ( k – 1 ) ⁄ M in Equation 5-2. This parameter has two settings, each with its advantages and disadvantages, as described in the following table. Twiddle factor computation Parameter Setting Sine and Cosine Computation Method Effect on Block Performance Table lookup The block computes and stores the trigonometric values before the simulation starts, and retrieves them during the simulation.
FFT the table of trigonometric values for speed or memory by varying the number of table entries as summarized in the following table.
FFT convolve signals by taking the FFT of time domain data, multiplying frequency-domain data, and inputting the product to an IFFT block. The following model shows the implementation of the Overlap-Save FFT Filter block. The implementation uses the FFT block in conjunction with an IFFT block, so the FFT block is set to output in bit-reversed order, and the IFFT block is set to accept inputs in bit-reversed order.
FFT Dialog Box Twiddle factor computation Computation method of the term e – j 2π ( m – 1 ) ( k – 1 ) ⁄ M in Equation 5-2. In Table lookup mode, the block computes and stores the sine and cosine values before the simulation starts. In Trigonometric fcn mode, the block computes the sine and cosine values during the simulation. See “Selecting the Twiddle Factor Computation Method” on page 5-177. Optimize table for Optimization of the table of sine and cosine values for Speed or Memory.
FFT See Also Complex Cepstrum DCT IFFT Pad Zero Pad bitrevorder fft ifft 5-182 DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset Signal Processing Toolbox Signal Processing Toolbox Signal Processing Toolbox
Filter Realization Wizard Purpose 5Filter Realization Wizard Library Filtering / Filter Designs Description The Filter Realization Wizard is a tool for automatically creating filter realizations with specific architectures. The Wizard’s interface allows you to specify the filter’s structure and coefficients, the type of data to be filtered, and optimization criteria for the design. The Wizard then builds the specified filter as a subsystem composed of Sum, Gain, and Unit Delay blocks.
Filter Realization Wizard Fixed-Point Options By default, the filter constructed by the Filter Realization Wizard operates using the Simulink standard double-precision arithmetic. If you have the Fixed-Point Blockset installed on your system, you have the additional option of building the filter to operate using single-precision or fixed-point arithmetic.
Filter Realization Wizard Example 1: Direct Form II Design an fourth-order, quarter-band, lowpass Butterworth filter: 1 At the MATLAB command line, compute the filter coefficients by entering [b,a] = butter(4,.25); 2 Launch the Filter Realization Wizard by double-clicking on the icon in the Filter Realizations library. 3 Configure the Wizard to use b and a as the numerator and denominator of a Direct-Form II structure: - Select Direct-Form II from the Type menu. - Type b in the Numerator text field.
Filter Realization Wizard 6 Double-click the new Butter LPF block to see the Direct-Form II filter realization that the Wizard created. Example 2: Second Order Sections Design an eighth-order, quarter-band, lowpass Butterworth filter using second-order sections (SOS): 1 At the MATLAB command line, compute the second-order sections by entering [a,b,c,d] = butter(4,.
Filter Realization Wizard 3 Type a name for the new filter subsystem in the Block Name field. The example uses Butter SOS. 4 Press the Build button to create the specified filter subsystem in a new model window. 5 Double-click the new Butter SOS block to see the Direct-Form II filter realization that the Wizard created. Note that in a subsystem with the Direct-Form I or II architecture, the filter sections are connected using From and Goto blocks rather than being directly wired together.
Filter Realization Wizard Numerator field. The two filter sections do not need to have the same order. - Type {a1,a2} in the Denominator text field. Note that the denominator coefficient vector for each section is also entered as an element in a cell array. Since this is a two-section filter, a two-cell array is specified in the Denominator field. 3 Type a name for the new filter subsystem in the Block Name field. The example uses Butter Sections.
Filter Realization Wizard [k,v] = tf2latc(b,a); Configure the Wizard to use k and v as the coefficients of the lattice design: - Select Lattice (ARMA) from the Type menu. - Type k in the Lattice Coeffs text field. - Type v in the Ladder Coeffs text field. 2 Type a name for the new filter subsystem in the Block Name field. The example uses Butter Lattice. 3 Press the Build button to create the specified filter subsystem in a new model window.
Filter Realization Wizard Dialog Box The parameters displayed in the Architecture panel vary for different selections in the Type menu. Only a portion of the parameters listed below are visible in the wizard at any one time. Type The filter architecture: Direct-Form I, Direct-Form II, Symmetric FIR, Lattice (MA), Lattice (AR), Lattice (ARMA). Numerator The numerator coefficients for the direct-form I and II structures, specified as a vector or variable name.
Filter Realization Wizard Lattice Coeffs The lattice coefficients for the lattice MA/AR/ARMA structures, specified as a vector or variable name. Ladder Coeffs The ladder coefficients for the lattice ARMA structure, specified as a vector or variable name. Optimize for zero gains Enables zero-gain optimization (when checked) by removing zero-gain paths from the filter structure. Optimize for unity gains Enables unity-gain optimization (when checked) by substituting a wire (short circuit) for unity gains.
Filter Realization Wizard Supported Data Types Fixed-point Single-precision floating point Supported only when you install the Fixed-Point Blockset Supported only when you install the Fixed-Point Blockset Double-precision floating point See Also Biquadratic Filter Direct-Form II Transpose Filter Discrete Filter Time-Varying Direct-Form II Transpose Filter Time-Varying Lattice Filter filter DSP Blockset DSP Blockset Simulink DSP Blockset DSP Blockset MATLAB See “Designing Filters with Various Filter
FIR Decimation Purpose 5FIR Decimation Library Filtering / Multirate Filters Description The FIR Decimation block resamples the discrete-time input at a rate K times slower than the input sample rate, where the integer K is specified by the Decimation factor parameter. This process consists of two steps: Filter and downsample an input signal. • The block filters the input data using a direct-form II transpose FIR filter.
FIR Decimation • Maintain input frame size The block generates the output at the slower (decimated) rate by using a proportionally longer frame period at the output port than at the input port. For decimation by a factor of K, the output frame period is K times longer than the input frame period (Tfo = KTfi), but the input and output frame sizes are equal.
FIR Decimation Latency Zero Latency. The FIR Decimation block has zero tasking latency for all single-rate operations. The block is single-rate for the particular combinations of sampling mode and parameter settings shown in the table below. Sampling Mode Parameter Settings Sample-based Decimation factor parameter, K, is 1. Frame-based Decimation factor parameter, K, is 1, or Framing parameter is Maintain input frame rate.
FIR Decimation samples K+1, 2K+1, and so on. See the example below for an illustration of this case. See “Excess Algorithmic Delay (Tasking Latency)” on page 3-91 and “The Simulation Parameters Dialog Box” in the Simulink documentation for more information about block rates and Simulink’s tasking modes. Examples Example 1 Construct the frame-based model shown below.
FIR Decimation The filter coefficient vector generated by fir1(3,0.25) is [0.0386 0.4614 0.4614 0.0386] or, equivalently, H ( z ) = B ( z ) = 0.0386 + 0.04614z –1 + 0.04614z –2 + 0.0386z –3 • Configure the Probe blocks by deselecting the Probe width, Probe complex signal, and Probe signal dimensions check boxes (if desired). This model is multirate because there are at least two distinct sample rates, as shown by the two Probe blocks.
FIR Decimation Dialog Box FIR filter coefficients The lowpass FIR filter coefficients, in descending powers of z. Decimation factor The integer factor, K, by which to decrease the sample rate of the input sequence. Framing For frame-based operation, the method by which to implement the decimation; reduce the output frame rate, or reduce the output frame size.
FIR Decimation • “Multirate Filters” on page 4-9 5-199
FIR Interpolation Purpose 5FIR Interpolation Library Filtering / Multirate Filters Description The FIR Interpolation block resamples the discrete-time input at a rate L times faster than the input sample rate, where the integer L is specified by the Interpolation factor parameter. This process consists of two steps: Upsample and filter an input signal. • The block upsamples the input to a higher rate by inserting L-1 zeros between samples.
FIR Interpolation • Maintain input frame size The block generates the output at the faster (interpolated) rate by using a proportionally shorter frame period at the output port than at the input port. For interpolation by a factor of L, the output frame period is L times shorter than the input frame period (Tfo = Tfi/L), but the input and output frame sizes are equal.
FIR Interpolation Latency Zero Latency. The FIR Interpolation block has zero tasking latency for all single-rate operations. The block is single-rate for the particular combinations of sampling mode and parameter settings shown in the table below. Sampling Mode Parameter Settings Sample-based Interpolation factor parameter, L, is 1. Frame-based Interpolation factor parameter, L, is 1, or Framing parameter is Maintain input frame rate.
FIR Interpolation input matrix) appears in the output as sample Mi+1, followed by L-1 interpolated values, the second filtered input sample, and so on. See the example below for an illustration of this case. See “Excess Algorithmic Delay (Tasking Latency)” on page 3-91 and “The Simulation Parameters Dialog Box” in the Simulink documentation for more information about block rates and Simulink’s tasking modes. Example Example 1 Construct the frame-based model shown below.
FIR Interpolation The filter coefficient vector generated by fir1(3,0.25) is [0.0386 0.4614 0.4614 0.0386] or, equivalently, H ( z ) = B ( z ) = 0.0386 + 0.04614z –1 + 0.04614z –2 + 0.0386z –3 • Configure the Probe blocks by deselecting the Probe width, Probe complex signal, and Probe signal dimensions check boxes (if desired). This model is multirate because there are at least two distinct sample rates, as shown by the two Probe blocks.
FIR Interpolation Dialog Box FIR filter coefficients The FIR filter coefficients, in descending powers of z. Interpolation factor The integer factor, L, by which to increase the sample rate of the input sequence. Framing For frame-based operation, the method by which to implement the interpolation: increase the output frame rate, or increase the output frame size.
FIR Interpolation • “Multirate Filters” on page 4-9 5-206
FIR Rate Conversion Purpose 5FIR Rate Conversion Library Filtering / Multirate Filters Description The FIR Rate Conversion block resamples the discrete-time input to a period K/L times the input sample period, where the integer K is specified by the Decimation factor parameter and the integer L is specified by the Interpolation factor parameter. The resampling process consists of the following steps: Upsample, filter, and downsample an input signal.
FIR Rate Conversion Frame-Based Operation This block accepts only frame-based inputs. An Mi-by-N frame-based matrix input is treated as N independent channels, and the block resamples each channel independently over time. The Interpolation factor, L, and Decimation factor, K, must satisfy the relation Mi K ---- = -------L Mo for an integer output frame size Mo. The simplest way to satisfy this requirement is to let the Decimation factor equal the input frame size, Mi.
FIR Rate Conversion Diagnostics An error is generated if the relation between K and L shown above is not satisfied. (Input port width)/(Output port width) must equal the (Decimation factor)/(Interpolation factor). A warning is generated if L and K are not relatively prime; that is, if the ratio L/K can be reduced to a ratio of smaller integers. Warning: Integer conversion factors are not relatively prime in block 'modelname/FIR Rate Conversion (Frame)'. Converting ratio L/M to l/m.
FIR Rate Conversion Supported Data Types Double-precision floating point See Also Downsample FIR Decimation FIR Interpolation Upsample fir1 fir2 firls remez upfirdn DSP Blockset DSP Blockset DSP Blockset DSP Blockset Signal Processing Toolbox Signal Processing Toolbox Signal Processing Toolbox Signal Processing Toolbox Signal Processing Toolbox See the following sections for related information: • “Converting Sample Rates and Frame Rates” on page 3-20 • “Multirate Filters” on page 4-9 5-210
Flip Purpose 5Flip Library Signal Management / Indexing Description The Flip block vertically or horizontally reverses the M-by-N input matrix, u. The output always has the same dimension and frame status as the input. Flip the input vertically or horizontally. When Columns is selected from the Flip along menu, the block vertically flips the input so that the first row of the input is the last row of the output.
Flip Supported Data Types Fixed-point Custom data types Boolean 8-, 16-, and 32-bit signed integer 8-, 16-, and 32-bit unsigned integer Single-precision floating point Double-precision floating point See Also Selector Transpose Variable Selector flipud fliplr 5-212 Simulink DSP Blockset DSP Blockset MATLAB MATLAB
Forward Substitution Purpose 5Forward Substitution Library Math Functions / Matrices and Linear Algebra / Linear System Solvers Description The Forward Substitution block solves the linear system LX=B by simple forward substitution of variables, where L is the lower triangular M-by-M matrix input to the L port, and B is the M-by-N matrix input to the B port. The output is the solution of the equations, the M-by-N matrix X, and is always sample-based.
Forward Substitution See “Solving Linear Systems” on page 4-16 for related information.
Frame Status Conversion Purpose 5Frame Status Conversion Library Signal Management / Signal Attributes Description The Frame Status Conversion block passes the input through to the output, and sets the output frame status to the Output signal parameter, which can be either Frame-based or Sample-based. The output frame status can also be inherited from the signal at the Ref (reference) input port, which is made visible by selecting the Inherit output frame status from Ref input port check box.
Frame Status Conversion Supported Data Types Fixed-point Custom data types Boolean 8-, 16-, and 32-bit signed integer 8-, 16-, and 32-bit unsigned integer Single-precision floating point Double-precision floating point See Also Check Signal Attributes Convert 1-D to 2-D Convert 2-D to 1-D Inherit Complexity 5-216 DSP Blockset DSP Blockset DSP Blockset DSP Blockset
From Wave Device Purpose 5From Wave Device Library DSP Sources Description The From Wave Device block reads audio data from a standard Windows audio device in real-time. It is compatible with most popular Windows hardware, including Sound Blaster cards. (Models that contain both this block and the To Wave Device block require a duplex-capable sound card.) Read audio data from a standard audio device in real-time.
From Wave Device The Sample Width (bits) parameter specifies the number of bits used to represent the signal samples read by the audio device. Two settings are available: • 8 – allocates 8 bits to each sample, allowing a resolution of 256 levels • 16 – allocates 16 bits to each sample, allowing a resolution of 65536 levels The 16-bit sample width setting requires more memory but yields better fidelity.
From Wave Device the signal sample rate was 8 kHz, this small buffer could hold approximately 0.005 second of data.) Simulink execution rate varies. board Hardware execution rate is No delays Simulation delay Hardware buffer with 5-frame capacity If the simulation throughput rate is higher than the hardware throughput rate, the buffer remains empty throughout the simulation.
From Wave Device length, the frame size, and the speed of the simulation. Note that increasing the buffer size may increase model latency. • Increase the simulation throughput rate Two useful methods for improving simulation throughput rates are increasing the signal frame size and compiling the simulation into native code: - Increase frame sizes (and convert sample-based signals to frame-based signals) throughout the model to reduce the amount of block-to-block communication overhead.
From Wave Device Sample rate (Hz) The sample rate of the audio data to be acquired. Select one of the standard Windows rates or the User-defined option. User-defined sample rate (Hz) The (nonstandard) sample rate of the audio data to be acquired. Sample width (bits) The number of bits used to represent each signal sample. Stereo Specifies stereo (two-channel) inputs when checked, mono (one-channel) inputs when unchecked. Stereo output is M-by-2; mono output is M-by-1.
From Wave File Purpose 5From Wave File Library DSP Sources Description The From Wave File block reads audio data from a Microsoft Wave (.wav) file and generates a double-precision signal with amplitudes in the range ±1. The audio data must be in uncompressed PCM (pulse code modulation) format. Read audio data from a Microsoft Wave (.wav) file. (Windows 95/98/NT only) y = wavread('filename') % Equivalent MATLAB code The File name parameter can specify an absolute or relative path to the file.
From Wave File Dialog Box File name The path and name of the file to read. Paths can be relative or absolute. Samples per output frame The number of samples in each output frame, M. Minimum number of samples for each read from file The number of consecutive samples to acquire from the file with each file access, L. Tunable.
Histogram Purpose 5Histogram Library Statistics Description The Histogram block computes the frequency distribution of the elements in each column of the input, or tracks the frequency distribution in a sequence of inputs over a period of time. The Running histogram parameter selects between basic operation and running operation, described below. Generate the histogram of an input or sequence of inputs.
Histogram For convenience, length-M 1-D vector inputs and sample-based length-M row vector inputs are both treated as M-by-1 column vectors. The output, y, is a sample-based n-by-N matrix whose jth column is the histogram for the data in the jth column of u. When the Normalized check box is selected, the block scales each column of the output so that sum(y(:,j)) is 1.
Histogram • Normalized = • Running histogram = The resulting bin width is 4, as shown below. Input Minimum value of input = -10 Maximum value of input = 10 Number of bins = 5 Output 2 4 3 6 0 # of occurrences 0 –2 6 – 12 2 5 4 3 0 4 3 –2 –3 –2 –9 -9 -12 -2 -2 -2 -3 2 0 0 -8 -4 0 6 5 4 4 3 3 4 8 Dialog Box Minimum value of input The lower boundary, Bm, of the lowest-valued bin.
Histogram Maximum value of input The upper boundary, BM, of the highest-valued bin. Number of bins The number of bins, n, in the histogram. Normalized Normalizes the output vector (1-norm) when selected. Tunable, except in Simulink’s external mode. Running histogram Enables running operation when selected. Reset port Enables the Rst input port when selected.
IDCT Purpose 5IDCT Library Transforms Description The IDCT block computes the inverse discrete cosine transform (IDCT) of each channel in the M-by-N input matrix, u. Compute the IDCT of the input. y = idct(u) % Equivalent MATLAB code For both sample-based and frame-based inputs, the block assumes that each input column is a frame containing M consecutive samples from an independent channel. The frame size, M, must be a power-of-two.
IDCT Dialog Box Supported Data Types Double-precision floating point See Also DCT IFFT idct DSP Blockset DSP Blockset Signal Processing Toolbox 5-229
Identity Matrix Purpose 5Identity Matrix Library DSP Sources, Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Identity Matrix block generates a rectangular matrix with ones on the main diagonal and zeros elsewhere. Generate a matrix with ones on the main diagonal and zeros elsewhere.
Identity Matrix Dialog Box Inherit input port attributes from input port Enables the input port when selected. The output inherits its dimensions and sample period from the input. Matrix size The number of rows and columns in the output matrix: a scalar M for a square M-by-M output, or a vector [M N] for an M-by-N output. This parameter is disabled when Inherit input port attributes from input port is selected. Sample time The discrete sample period of the output.
IFFT Purpose 5IFFT Library Transforms Description The IFFT block computes the inverse fast Fourier transform (IFFT) of each channel in the M-by-N or length-M input, u, where M must be a power of two. To work with other input sizes, use the Zero Pad block to pad or truncate the length-M dimension to a power-of-two length. The output is always frame-based, and each output column contains the M-point inverse discrete Fourier transform (IDFT) of the corresponding input channel.
IFFT Input and Output Characteristics The following table describes all valid block input types, their corresponding outputs, and the dimension along which the block computes the IDFT. Note For M-by-N and length-M inputs, M must be a power of two. To work with other input sizes, use the Zero Pad block to pad or truncate the length-M dimension to a power-of-two length. To get valid outputs, you must correctly set the Input is in bit-reversed order parameter to indicate the ordering of the block input.
IFFT Valid Block Inputs • Must be complex-valued • M must be a power of two Dimension Along Which Block Computes IDFT Corresponding Block Output Characteristics Output port rate = input port rate • In linear or bit-reversed order Frame-based M-by-N matrix Column Sample-based M-by-N matrix, M ≠ 1 Column Sample-based 1-by-M row vector Row 1-D length-M vector Vector The following output characteristics apply to all valid block inputs: • Frame-based • Complex-valued unless you set the Input is con
IFFT Click here in the MATLAB Help Browser to open a Simulink model based on the following diagram. Effects of Block Input Size, Dimension, and Frame Status on Block Output 1 2 3 4 2 4 6 8 3 6 9 12 1 2 3 4 2 4 6 8 3 6 9 12 1234 Frame-based 4-by-3 input Frame-based 4-by-3 output Compute IFFT of each column Sample-based 4-by-3 nonrow input Frame-based 4-by-3 output Compute IFFT of each column Sample-based 1-by-4 row vector input Frame-based 1-by-4 output 2.5 5 7.5 – 0.5 – 0.5i – 1 – i – 1.
IFFT The block output is invalid if you set this parameter when the input is not conjugate symmetric. Inputs in Bit-Reversed Order When the block input is in bit-reversed order, you must set the parameter Input is in bit-reversed order to get a valid output. The block output is invalid if you set this parameter when the input is not in bit-reversed order. A common source of bit-reversed inputs is the FFT block, as illustrated in the FFT block example, “Use of Outputs in Bit-Reversed Order” on page 5-179.
IFFT Input Complexity Other Parameter Settings Algorithms Used for FFT Computation Complex not applicable Radix-2 DIT Real Radix-2 DIT Real Radix-2 DIT in conjunction with the half-length and double-signal algorithms when possible Example For an example of how to optimize computations when using both the IFFT block and FFT block in the same model, see the FFT block reference page example, “Use of Outputs in Bit-Reversed Order” on page 5-179.
IFFT values before the simulation starts. In Trigonometric fcn mode, the block computes the sine and cosine values during the simulation. Optimize table for Optimization of the table of sine and cosine values for Speed or Memory. Active only when Twiddle factor computation is set to Table lookup. Input is in bit-reversed order Set when the input is in bit-reversed order, and clear when the input is in linear order. The block yields invalid outputs if you do not set this parameter correctly.
Inherit Complexity Purpose 5Inherit Complexity Library Signal Management / Signal Attributes Description The Inherit Complexity block alters the input data at the Data port to match the complexity of the reference input at the Ref port. If the Data input is real, and the Ref input is complex, the block appends a zero-valued imaginary component, 0i, to each element of the Data input. Ref 0 1 2 3 4 5+ i 3-2i 0+ i 2-5i 2-5i 0+0i 1+0i 2+0i 3+0i 4+0i ... ... Output Data ...
Inherit Complexity Dialog Box Supported Data Types Fixed-point Custom data types Boolean 8-, 16-, and 32-bit signed integer 8-, 16-, and 32-bit unsigned integer Single-precision floating point Double-precision floating point See Also Check Signal Attributes Complex to Magnitude-Angle Complex to Real-Imag Magnitude-Angle to Complex Real-Imag to Complex 5-240 DSP Blockset Simulink Simulink Simulink Simulink
Integer Delay Purpose 5Integer Delay Library Signal Operations Description The Integer Delay block delays a discrete-time input by the number of sample intervals specified in the Delay parameter. Noninteger delay values are rounded to the nearest integer, and negative delays are clipped at 0. Delay an input by an integer number of sample periods. Sample-Based Operation When the input is a sample-based M-by-N matrix, the block treats each of the M∗N matrix elements as an independent channel.
Integer Delay the block generates the following sequence of matrices at the start of the simulation, –1 –1 1 , –1 –1 u 11 – 1 –1 –1 2 , 1 3 2 4 3 u 11 u 12 u 11 u 12 u 11 u 12 , , ,… 1 2 1 –1 –1 u 21 – 1 u 21 u 22 k where u ij is the i,jth element of the kth matrix in the input sequence. • Array of size M-by-N-by-d. In this case, you can set different fixed initial conditions for each element of a sample-based input.
Integer Delay of the array are output in sequence, one at each sample time of the initial delay. For a 2-by-3 input, and the parameters below, the block outputs the matrix sequence 1 2 3, 2 4 6, 3 6 9 4 5 6 1 3 5 0 4 8 at the start of the simulation. Note that setting Initial conditions to an array with the same matrix for each entry implements constant initial conditions; a different constant initial condition for each input matrix element (channel).
Integer Delay The Initial conditions parameter specifies the output during the initial delay. Both fixed and time-varying initial conditions can be specified. The initial delay for a particular channel is the time elapsed from the start of the simulation until the first input in that channel is propagated to the output. Fixed Initial Conditions. The settings shown below specify fixed initial conditions.
Integer Delay - When the all elements of the delay entry are greater than the input frame size, D = d + input frame size - 1 Only the first d entries of the initial condition vector will be used; the rest of the values are ignored, but you must include them nonetheless. For a two-channel ramp input [1:100; 1:100]' with a frame size of 4 and the parameter settings below, the block outputs the following sequence of frames at the start of the simulation.
Integer Delay the block outputs the following sequence of frames at the start of the simulation. –1 –2 –3 –4 4 4 1 , 5 5 ,… 2 6 6 7 7 3 – 9 – 10 , 1 2 –5 –6 –7 –8 3 Note that the channels have distinct time varying initial conditions; the initial conditions for channel 1 correspond to the first entry of each length-2 row vector in the initial conditions array, and the initial conditions for channel 2 correspond to the second entry of each row vector in the initial conditions array.
Integer Delay Simulation time [1 [2 [3 [4 [5 [6 [7 [8 [9 1 2 3 4 5 6 7 8 9 1] 2] 3] 4] 5] 6] 7] 8] 9] ch1 ch2 ch3 Output ch1 ch2 ch3 Input First input (sample-based) 1 2 3 4 5 6 7 8 9 0] 0] 0] 0] 0] 1] 2] 3] 4] First output ... ... Delay: [2 0 5] Initial conditions: 0 [0 [0 [1 [2 [3 [4 [5 [6 [7 Dialog Box Delay The number of sample periods to delay the input signal. Initial conditions The value of the block’s output during the initial delay.
Integer Delay Supported Data Types Fixed-point Custom data types Boolean 8-, 16-, and 32-bit signed integer 8-, 16-, and 32-bit unsigned integer Single-precision floating point Double-precision floating point See Also Unit Delay Variable Fractional Delay Variable Integer Delay 5-248 Simulink DSP Blockset DSP Blockset
Kalman Adaptive Filter Purpose 5Kalman Adaptive Filter Library Filtering / Adaptive Filters Description The Kalman Adaptive Filter block computes the optimal linear minimum mean-square estimate (MMSE) of the FIR filter coefficients using a one-step predictor algorithm. This Kalman filter algorithm is based on the following physical realization of a dynamical system. Compute filter estimates for an input using the Kalman adaptive filter algorithm.
Kalman Adaptive Filter The variables are as follows.
Kalman Adaptive Filter Block Ports Corresponding Variables In u, the scalar input, which is internally buffered into the vector u(n) Out y(n), the filtered scalar output Err e(n), the scalar estimation error Taps ŵ ( n ) , the vector of filter-tap estimates An optional Adapt input port is added when the Adapt input check box is selected in the dialog box. When this port is enabled, the block continuously adapts the filter coefficients while the Adapt input is nonzero.
Kalman Adaptive Filter Dialog Box FIR filter length The length of the FIR filter. Measurement noise variance The value to appear along the diagonal of the measurement noise correlation matrix. Tunable. Process noise variance The value to appear along the diagonal of the process noise correlation matrix. Tunable. Initial value of filter taps The initial FIR filter coefficients. Initial error correlation matrix The initial value of the error correlation matrix. Adapt input Enables the Adapt port.
Kalman Adaptive Filter Supported Data Types Double-precision floating point See Also LMS Adaptive Filter RLS Adaptive Filter DSP Blockset DSP Blockset See “Adaptive Filters” on page 4-3 for related information.
LDL Factorization Purpose 5LDL Factorization Library Math Functions / Matrices and Linear Algebra / Matrix Factorizations Description The LDL Factorization block uniquely factors the square Hermitian positive definite input matrix S as Factor a square Hermitian positive definite matrix into lower, upper, and diagonal components. S = LDL * where L is a lower triangular square matrix with unity diagonal elements, D is a diagonal matrix, and L* is the Hermitian (complex conjugate) transpose of L.
LDL Factorization The following options are available: • Ignore – Proceed with the computation and do not issue an alert. The output is not a valid factorization. A partial factorization will be present in the upper left corner of the ouput. • Warning – Display a warning message in the MATLAB command window, and continue the simulation. The output is not a valid factorization. A partial factorization will be present in the upper left corner of the ouput.
LDL Factorization Supported Data Types Double-precision floating point See Also Cholesky Factorization LDL Inverse LDL Solver LU Factorization QR Factorization DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset See “Factoring Matrices” on page 4-17 for related information.
LDL Inverse Purpose 5LDL Inverse Library Math Functions / Matrices and Linear Algebra / Matrix Inverses Description The LDL Inverse block computes the inverse of the Hermitian positive definite input matrix S by performing an LDL factorization. Compute the inverse of a Hermitian positive definite matrix using LDL factorization.
LDL Inverse Non-positive definite input Response to non-positive definite matrix inputs. Tunable. References Golub, G. H., and C. F. Van Loan. Matrix Computations. 3rd ed. Baltimore, MD: Johns Hopkins University Press, 1996. Supported Data Types Double-precision floating point See Also Cholesky Inverse LDL Factorization LDL Solver LU Inverse Pseudoinverse inv DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset MATLAB See “Inverting Matrices” on page 4-19 for related information.
LDL Solver Purpose 5LDL Solver Library Math Functions / Matrices and Linear Algebra / Linear System Solvers Description The LDL Solver block solves the linear system SX=B by applying LDL factorization to the matrix at the S port, which must be square (M-by-M) and Hermitian positive definite. Only the diagonal and lower triangle of the matrix are used, and any imaginary component of the diagonal entries is disregarded. The input to the B port is the right-hand side M-by-N matrix, B.
LDL Solver 1 Substitute * Y = DL X 2 Substitute * Z = L X 3 Solve one diagonal and two triangular systems. LY = B DZ = Y * L X = Z Dialog Box Non-positive definite input Response to non-positive definite matrix inputs. Tunable.
Least Squares Polynomial Fit Purpose 5Least Squares Polynomial Fit Library Math Functions / Polynomial Functions Description The Least Squares Polynomial Fit block computes the coefficients of the nth order polynomial that best fits the input data in the least-squares sense, where n is specified by the Polynomial order parameter. A distinct set of n+1 coefficients is computed for each column of the M-by-N input, u.
Least Squares Polynomial Fit to generate four values of dependent variable y from four values of independent variable u, received at the top port. The polynomial coefficients are supplied in the vector [-2 0 3] at the bottom port. Note that the coefficient of the first-order term is zero. The Control points parameter of the Least Squares Polynomial Fit block is configured with the same four values of independent variable u that are used as input to the Polynomial Evaluation block, [1 2 3 4].
Least Squares Polynomial Fit Supported Data Types Double-precision floating point See Also Detrend Polynomial Evaluation Polynomial Stability Test polyfit DSP Blockset DSP Blockset DSP Blockset MATLAB 5-263
Levinson-Durbin Purpose 5Levinson-Durbin Library Math Functions / Matrices and Linear Algebra / Linear System Solvers Description The Levinson-Durbin block solves the nth-order system of linear equations Solve a linear system of equations using Levinson-Durbin recursion. Ra = b for the particular case where R is a Hermitian, positive-definite, Toeplitz matrix and b is identical to the first column of R shifted by one element and with the opposite sign.
Levinson-Durbin The prediction error power, P, (a scalar), is output when the Output prediction error power (P) check box is selected. P represents the power of the output of an FIR filter with taps A and input autocorrelation described by r, where A represents a prediction error filter and r is the input to the block. (In this case, A is a whitening filter).
Levinson-Durbin average (MA) process (or FIR filter) that predicts the next value of a signal from the current signal sample and a finite number of past samples. In this case, the input to the block represents the signal’s autocorrelation sequence, with r(1) being the zero-lag value, and the output at the block’s A port contains the coefficients of the predictive MA process (in descending powers of z).
Levinson-Durbin Output prediction error power (P) When selected, the block outputs the prediction error at port P. If the value of lag 0 is zero, A=[1 zeros], K=[zeros], P=0 When selected, the block outputs a zero-vector for inputs having r(1) = 0. When unselected, the block outputs NaNs for these inputs. References Golub, G. H., and C. F. Van Loan. Sect. 4.7 in Matrix Computations. 3rd ed. Baltimore, MD: Johns Hopkins University Press, 1996. Ljung, L. System Identification: Theory for the User.
LMS Adaptive Filter Purpose 5LMS Adaptive Filter Library Filtering / Adaptive Filters Description The LMS Adaptive Filter block implements an adaptive FIR filter using the stochastic gradient algorithm known as the normalized Least Mean-Square (LMS) algorithm. Compute filter estimates for an input using the LMS adaptive filter algorithm.
LMS Adaptive Filter scalars. The signal at the Out port is a scalar, while the signal at the Taps port is a sample-based vector. Block Ports Corresponding Variables In u, the scalar input, which is internally buffered into the vector u(n) Out y(n), the filtered scalar output Err e(n), the scalar estimation error Taps ŵ ( n ) , the vector of filter-tap estimates An optional Adapt input port is added when the Adapt input check box is selected in the dialog box.
LMS Adaptive Filter Dialog Box FIR filter length The length of the FIR filter. Step-size The step size, usually in the range (0, 2). Tunable. Initial value of filter taps The initial FIR filter coefficients. Leakage factor The leakage factor, in the range [0, 1]. Tunable. Use normalization Select or deselect normalization. Adapt input Enables the Adapt port. References Haykin, S. Adaptive Filter Theory. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1996.
LMS Adaptive Filter See Also Kalman Adaptive Filter RLS Adaptive Filter DSP Blockset DSP Blockset See “Adaptive Filters” on page 4-3 for related information.
LU Factorization Purpose 5LU Factorization Library Math Functions / Matrices and Linear Algebra / Matrix Factorizations Description The LU Factorization block factors a row permutation of the square input matrix A as Factor a square matrix into lower and upper triangular components. A p = LU where L is a lower-triangular square matrix with unity diagonal elements, and U is an upper-triangular square matrix.
LU Factorization Dialog Box References Golub, G. H., and C. F. Van Loan. Matrix Computations. 3rd ed. Baltimore, MD: Johns Hopkins University Press, 1996. Supported Data Types Double-precision floating point See Also Autocorrelation LPC Cholesky Factorization LDL Factorization LU Inverse LU Solver Permute Matrix QR Factorization lu DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset MATLAB See “Factoring Matrices” on page 4-17 for related information.
LU Inverse Purpose 5LU Inverse Library Math Functions / Matrices and Linear Algebra / Matrix Inverses Description The LU Inverse block computes the inverse of the square input matrix A by factoring and inverting row-pivoted variant Ap. Compute the inverse of a square matrix using LU factorization. –1 A p = ( LU ) –1 L is a lower-triangular square matrix with unity diagonal elements, and U is an upper-triangular square matrix. The block’s output is A-1, and is always sample-based.
LU Solver Purpose 5LU Solver Library Math Functions / Matrices and Linear Algebra / Linear System Solvers Description The LU Solver block solves the linear system AX=B by applying LU factorization to the M-by-M matrix at the A port. The input to the B port is the right-hand side M-by-N matrix, B. The output is the unique solution of the equations, M-by-N matrix X, and is always sample-based. Solve the equation AX=B for X when A is a square matrix.
LU Solver Supported Data Types Double-precision floating point See Also Autocorrelation LPC Cholesky Solver LDL Solver Levinson-Durbin LU Factorization LU Inverse QR Solver DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset See “Solving Linear Systems” on page 4-16 for related information.
Magnitude FFT Purpose 5Magnitude FFT Library Estimation / Power Spectrum Estimation Description The Magnitude FFT block computes a nonparametric estimate of the spectrum using the periodogram method. When the Output parameter is set to Magnitude squared, the block output for an input u is equivalent to Compute a nonparametric estimate of the spectrum using the periodogram method. y = abs(fft(u,nfft)).
Magnitude FFT Dialog Box Output Determines whether the block computes the magnitude FFT (Magnitude) or magnitude-squared FFT (Magnitude squared) of the input. Tunable. Inherit FFT length from input dimensions When selected, uses the input frame size as the number of data points, Nfft, on which to perform the FFT. FFT size The number of data points on which to perform the FFT, Nfft. If Nfft exceeds the input frame size, the frame is zero-padded as needed.
Magnitude FFT See Also Burg Method Short-Time FFT Spectrum Scope Yule-Walker Method pwelch DSP Blockset DSP Blockset DSP Blockset DSP Blockset Signal Processing Toolbox See “Power Spectrum Estimation” on page 4-15 for related information.
Matrix 1-Norm Purpose 5Matrix 1-Norm Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Matrix 1-Norm block computes the 1-norm, or maximum column-sum, of an M-by-N input matrix, A. Compute the 1-norm of a matrix.
Matrix 1-Norm Supported Data Types Double-precision floating point See Also Normalization Reciprocal Condition norm DSP Blockset DSP Blockset MATLAB 5-281
Matrix Multiply Purpose 5Matrix Multiply Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Matrix Multiply block multiplies n input matrices, A, B, C, ..., Un, in the forward direction, where n is specified by the Number of input ports parameter and Un is the input at the nth port. Multiply input matrices. Y = ((((A*B)*C)*D) ...
Matrix Multiply See Also Dot Product Matrix Product Matrix Scaling Product Simulink DSP Blockset DSP Blockset Simulink 5-283
Matrix Product Purpose 5Matrix Product Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Matrix Product block multiplies the elements of an M-by-N input matrix u along either the rows or columns. Multiply the elements of a matrix along rows or columns. When the Multiply along parameter is set to Rows, the block multiplies across the elements of each row and outputs the resulting M-by-1 matrix. A length-N 1-D vector input is treated as a 1-by-N matrix.
Matrix Product Dialog Box Multiply along The dimension of the matrix along which to multiply, row or column.
Matrix Scaling Purpose 5Matrix Scaling Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Matrix Scaling block scales the rows or columns of the M-by-N input matrix A by the values in input vector D. Scale the rows or columns of a matrix by a specified vector. When the Mode parameter is set to Scale Rows (D*A), input D can be a 1-D or 2-D vector of length M, and the block multiplies each element of D across the corresponding row of matrix A.
Matrix Scaling Dialog Box Mode The mode of operation, row scaling or column scaling. Tunable.
Matrix Square Purpose 5Matrix Square Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Matrix Square block computes the square of an M-by-N input matrix, u, by premultiplying with the Hermitian transpose. Compute the square of the input matrix. y = u' * u % Equivalent MATLAB code A length-M 1-D vector input is treated as an M-by-1 matrix. For both sample-based and frame-based inputs, output y is sample-based with dimension N-by-N.
Matrix Square See Also Matrix Multiply Matrix Product Matrix Sum Transpose DSP Blockset DSP Blockset DSP Blockset DSP Blockset 5-289
Matrix Sum Purpose 5Matrix Sum Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Matrix Sum block sums the elements of an M-by-N input matrix u along either the rows or columns. Sum the elements of a matrix along rows or columns. When the Sum along parameter is set to Rows, the block sums across the elements of each row and outputs the resulting M-by-1 matrix. A length-N 1-D vector input is treated as a 1-by-N matrix.
Matrix Sum Dialog Box Sum along The dimension of the matrix to sum along, row or column.
Matrix Viewer Purpose 5Matrix Viewer Library DSP Sinks Description The Matrix Viewer block displays an M-by-N matrix input by mapping the matrix element values to a specified range of colors. The display is updated as each new input is received. (A length-M 1-D vector input is treated as an M-by-1 matrix.) Display a matrix as a color image. Image Properties Click on the Image properties check box to expose the image property parameters, which control the colormap and display.
Matrix Viewer Axis Properties Click on the Axis properties check box to expose the axis property parameters, which control labeling and positioning. The Axis origin parameter determines where the first element of the input matrix, U(1,1), is displayed. When Upper left corner is specified, the matrix is displayed in matrix orientation, with U(1,1) in the upper-left corner.
Matrix Viewer 1 to N (number of columns), and the y-axis is numbered from 1 to M (number of rows). In addition to the standard MATLAB figure window menus (File, Edit, Window, Help), the Matrix Viewer window has an Axes menu containing the following items: • Refresh erases all data on the scope display, except for the most recent image. • Autoscale recomputes the Minimum input and Maximum input parameter values to best fit the range of values observed in a series of 10 consecutive inputs.
Matrix Viewer Dialog Box Image properties Select to expose the image property parameters. Tunable. Colormap matrix A 3-column matrix defining the colormap as a set of RGB triples, or a call to a colormap-generating function such as hot or spring. See the ColorSpec property for complete information about defining RGB triples, and the colormap function for a list of colormap-generating functions. Tunable.
Matrix Viewer Maximum input value The input value to be mapped to the color defined in the last row of the colormap matrix. Select Autoscale from the right-click pop-up menu to set this parameter to the maximum value observed in a series of 10 consecutive matrix inputs. Tunable. Display colorbar Select to display a bar with the selected colormap to the right of the image axes. Tunable. Axis properties Select to expose the axis property parameters. Tunable.
Matrix Viewer Supported Data Types Fixed-point Custom data types Boolean 8-, 16-, and 32-bit signed integer 8-, 16-, and 32-bit unsigned integer Single-precision floating point Double-precision floating point See Also Spectrum Scope Vector Scope colormap ColorSpec image DSP Blockset DSP Blockset MATLAB MATLAB MATLAB See “Viewing Signals” on page 3-80 for related information.
Maximum Purpose 5Maximum Library Statistics Description The Maximum block identifies the value and position of the largest element in each column of the input, or tracks the maximum values in a sequence of inputs over a period of time. The Mode parameter specifies the block’s mode of operation and can be set to Value, Index, Value and Index, or Running. Find the maximum values in an input or sequence of inputs.
Maximum and outputs the sample-based 1-by-N index vector, idx. Each value in idx is an integer in the range [1 M] indexing the maximum value in the corresponding column of u. As in Value mode, length-M 1-D vector inputs and sample-based length-M row vector inputs are both treated as M-by-1 column vectors. If a maximum value occurs more than once in a particular column of u, the computed index corresponds to the first occurrence.
Maximum For sample-based inputs, a reset event causes the running maximum for each channel to be initialized to the value in the corresponding channel of the current input. For frame-based inputs, a reset event causes the running maximum for each channel to be initialized to the earliest value in each channel of the current input. The Rst port can be disabled by selecting None from the Reset port menu.
Maximum The block’s operation is shown in the figure below. In ch1 Simulation time First input Output Rst ch2 ch1 ch2 61 13 39 t=0 0 –7 2 2 4 5 1 t=1 0 69 69 69 8 6 0 2 –1 5 t=2 1 86 86 86 –3 0 2 4 1 17 t=3 0 8 6 8 6 8 17 First output 61 63 69 Reset The statsdem demo illustrates the operation of several blocks from the Statistics library.
Maximum index (Value and index), or track the maximum value of the input sequence over time (Running). Reset port Specifies the reset event detected at the Rst input port when Running is selected as the Mode parameter. The reset operation can be set to occur when a rising and/or falling edge is detected at the Rst port, (Rising edge, Falling edge, Either Edge), or when a non-zero sample is detected at the Rst port (Non-zero sample). The Rst port can be disabled by selecting None.
Mean Purpose 5Mean Library Statistics Description The Mean block computes the mean of each column in the input, or tracks the mean values in a sequence of inputs over a period of time. The Running mean parameter selects between basic operation and running operation. Find the mean value of an input or sequence of inputs. Basic Operation When the Running mean check box is not selected, the block computes the mean of each column of M-by-N input matrix u independently at each sample time.
Mean element yij containing the mean value of the jth column over all inputs since the last reset, up to and including element uij of the current input. If the Reset port parameter is set to Non-zero sample, the optional Rst port is enabled and the block resets the running mean when the scalar input at the Rst port is nonzero. (The Rst port can be disabled by setting the Reset port parameter to None.
Mean The Discrete Impulse block has the following settings: • Delay (samples) = 2 • Sample time = 1 • Samples per frame = 1 The block’s operation is shown in the figure below. In ch1 Simulation time First input Output Rst ch1 ch2 61 13 39 t=0 0 –7 2 2 4 5 1 t=1 0 8 6 0 2 –1 5 t=2 1 –3 0 2 4 1 17 t=3 0 First output ch2 6.00 1.00 3.50 2.00 3.33 4.33 0.75 3.75 1.00 3.80 1.67 3.33 Reset 8.00 6.00 4.00 4.00 2.33 4.33 1.00 3.25 1.20 3.40 1.17 5.
Mean Running mean Enables running operation when selected. Reset port Enables the Rst input port when set to Non-zero sample, and disables the Rst input port when set to None.
Median Purpose 5Median Library Statistics Description The Median block computes the median value of each column in an M-by-N input matrix. Find the median value of an input. y = median(u) % Equivalent MATLAB code For convenience, length-M 1-D vector inputs and sample-based length-M row vector inputs are both treated as M-by-1 column vectors. The output at each sample time, y, is a sample-based 1-by-N vector containing the median value for each column in u.
Median See Also Maximum Mean Minimum Sort Standard Deviation Variance median 5-308 DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset MATLAB
Minimum Purpose 5Minimum Library Statistics Description The Minimum block identifies the value and position of the smallest element in each column of the input, or tracks the minimum values in a sequence of inputs over a period of time. The Mode parameter specifies the block’s mode of operation, and can be set to Value, Index, Value and Index, or Running. Find the minimum values in an input or sequence of inputs.
Minimum and outputs the sample-based 1-by-N index vector, idx. Each value in idx is an integer in the range [1 M] indexing the minimum value in the corresponding column of u. As in Value mode, length-M 1-D vector inputs and sample-based length-M row vector inputs are both treated as M-by-1 column vectors. If a minimum value occurs more than once in a particular column of u, the computed index corresponds to the first occurrence.
Minimum The Minimum block has the following settings: • Mode = Running • Reset port = Non-zero sample The Signal From Workspace block has the following settings: • Signal = u • Sample time = 1/3 • Samples per frame = 3 where u = [6 1 3 -7 2 5 8 0 -1 -3 2 1;1 3 9 2 4 2 6 2 5 0 4 17]' The Discrete Impulse block has the following settings: • Delay (samples) = 2 • Sample time = 1 • Samples per frame = 1 The block’s operation is shown in the figure below.
Minimum In ch1 Simulation time First input Output Rst ch2 ch1 ch2 61 13 39 t=0 0 –7 2 2 4 5 2 t=1 0 –7 1 –7 1 –7 1 8 6 0 2 –1 5 t=2 1 8 6 0 2 –1 2 –3 0 2 4 1 17 t=3 0 –3 0 –3 0 –3 0 First output 61 11 11 Reset Dialog Box Mode The block’s mode of operation: Output the minimum value of each input (Value), the index of the minimum value (Index), both the value and the index (Value and Index), or track the minimum values in the input sequence over time (Running).
Minimum Supported Data Types Double-precision floating point See Also Maximum Mean MinMax Histogram min DSP Blockset DSP Blockset Simulink DSP Blockset MATLAB 5-313
Modified Covariance AR Estimator Purpose 5Modified Covariance AR Estimator Library Estimation / Parametric Estimation Description The Modified Covariance AR Estimator block uses the modified covariance method to fit an autoregressive (AR) model to the input data. This method minimizes the forward and backward prediction errors in the least-squares sense. The input is a frame of consecutive time samples, which is assumed to be the output of an AR system driven by white noise.
Modified Covariance AR Estimator Marple, S. L., Jr., Digital Spectral Analysis with Applications. Englewood Cliffs, NJ: Prentice-Hall, 1987.
Modified Covariance Method Purpose 5Modified Covariance Method Library Estimation / Power Spectrum Estimation Description The Modified Covariance Method block estimates the power spectral density (PSD) of the input using the modified covariance method. This method fits an autoregressive (AR) model to the signal by minimizing the forward and backward prediction errors in the least-squares sense.
Modified Covariance Method Dialog Box Estimation order The order of the AR model. Inherit FFT length from input dimensions When selected, uses the input frame size as the number of data points, Nfft, on which to perform the FFT. Tunable. FFT length The number of data points, Nfft, on which to perform the FFT. If Nfft exceeds the input frame size, the frame is zero-padded as needed. This parameter is enabled when Inherit FFT length from input dimensions is not selected. References Kay, S. M.
Modified Covariance Method See “Power Spectrum Estimation” on page 4-15 for related information.
Multiphase Clock Purpose 5Multiphase Clock Library Signal Management / Switches and Counters Description The Multiphase Clock block generates a sample-based 1-by-N vector of clock signals, where the integer N is specified by the Number of phases parameter. Each of the N phases has the same frequency, f, specified in hertz by the Clock frequency parameter. Generate multiple binary clock signals. The clock signal indexed by the Starting phase parameter is the first to become active, at t=0.
Multiphase Clock The Scope window below shows the Multiphase Clock block’s output for these settings. Note that the first active level appears at t=0 on y(3), the second active level appears at t=0.002 on y(4), the third active level appears at t=0.004 on y(5), the fourth active level appears at t=0.006 on y(1), and the fifth active level appears at t=0.008 on y(2). Each signal becomes active 1/(5∗100) seconds after the previous signal.
Multiphase Clock Dialog Box Clock frequency The frequency of all output clock signals. Number of phases The number of different phases, N, in the output vector. Starting phase The vector index of the output signal to first become active. Tunable. Number of phase intervals over which clock is active The duration of the active level for every output signal. Tunable. Active level The active level, high (1) or low (0). Tunable.
Multiport Selector Purpose 5Multiport Selector Library Signal Management / Indexing Description The Multi-port Selector block extracts multiple subsets of rows or columns from M-by-N input matrix u, and propagates each new submatrix to a distinct output port. A length-M 1-D vector input is treated as an M-by-1 matrix. Distribute arbitrary subsets of input rows or columns to multiple output ports.
Multiport Selector Example Consider the following Indices to output cell array: {4,[1:2 5],[7;8],10:-1:6} This is a four-cell array, which requires the block to generate four independent outputs (each at a distinct port). The table below shows the dimensions of these outputs when Select = Rows and the input dimension is M-by-N.
Multiport Selector Invalid index Response to an invalid index value. Tunable.
N-Sample Enable Purpose 5N-Sample Enable Library DSP Sources, Signal Management / Switches and Counters Description The N-Sample Enable block outputs the inactive value (0 or 1, whichever is not selected in the Active level parameter) during the first N sample times, where N is the Trigger count value. Beginning with output sample N+1, the block outputs the active value (1 or 0, whichever is selected in the Active level parameter) until a reset event occurs or the simulation terminates.
N-Sample Enable Trigger count The number of samples for which the block outputs the active value. Tunable. Active level The value to output after the first N sample times, 0 or 1. Tunable. Reset input Enables the Rst input port. Trigger type The type of event that triggers a reset when the Rst port is enabled. Tunable. Sample time The sample period, Ts, for the block’s counter. The block switches from the active value to the inactive value at t=Ts∗(N+1).
N-Sample Switch Purpose 5N-Sample Switch Library Signal Management / Switches and Counters Description The N-Sample Switch block outputs the signal connected to the top input port during the first N sample times after the simulation begins or the block is reset, where N is specified by the Switch count value. Beginning with output sample N+1, the block outputs the signal connected to the bottom input until the next reset event or the end of the simulation.
N-Sample Switch Dialog Box Switch count The number of sample periods, N, for which the output is connected to the top input before switching to the bottom input. Tunable. Reset input Enables the Rst input port when selected. Trigger type The type of event at the Rst port that resets the block’s counter. This parameter is enabled when Reset input is selected. Tunable. Sample time The sample period, Ts, for the block’s counter. The block switches inputs at t=Ts∗(N+1).
Normalization Purpose 5Normalization Library Math Functions / Math Operations Description The Normalization block independently normalizes each column of the M-by-N matrix input, u. Normalize an input by its 2-norm or squared 2-norm. 2-Norm When the Norm parameter specifies 2-norm, the block normalizes the jth input column as follows. u ij y ij = --------------------u j+b where b is specified by the Normalization bias parameter, and u j is the 2-norm (or Euclidean norm) of the jth input column.
Normalization The output has the same dimension and frame status as the input. For convenience, length-M 1-D vector inputs and sample-based length-M row vector inputs are both treated as M-by-1 column vectors, and the output retains the dimensions of the input. Dialog Box Norm The type of normalization to apply, 2-norm or Squared 2-norm. Tunable. Normalization bias The value b to be added in the denominator to avoid division by zero. Tunable.
Overlap-Add FFT Filter Purpose 5Overlap-Add FFT Filter Library Filtering / Filter Designs Description The Overlap-Add FFT Filter block uses an FFT to implement the overlap-add method, a technique that combines successive frequency-domain filtered sections of an input sequence. Implement the overlap-add method of frequency-domain filtering. Valid inputs to this block are 1-D vectors, sample-based vectors, frame-based vectors, and frame-based full matrices.
Overlap-Add FFT Filter If either the filter coefficients or the inputs to the block are complex, the Output parameter should be set to Complex. Otherwise, the default Output setting, Real, instructs the block to take only the real part of the solution. The block’s overlap-add operation is equivalent to y = ifft(fft(u(i:i+L-1),nfft) .* fft(b,nfft)) where nfft is specified by the FFT size parameter as a power-of-two value greater (typically much greater) than n+1.
Overlap-Add FFT Filter Dialog Box FFT size The size of the FFT, which should be a power-of-two value greater than the length of the specified FIR filter. FIR coefficients The filter numerator coefficients. Output The complexity of the output; Real or Complex. If the input signal or the filter coefficients are complex, this should be set to Complex. References Oppenheim, A. V. and R. W. Schafer. Discrete-Time Signal Processing. Englewood Cliffs, NJ: Prentice Hall, 1989. Proakis, J. and D. Manolakis.
Overlap-Save FFT Filter Purpose 5Overlap-Save FFT Filter Library Filtering / Filter Designs Description The Overlap-Save FFT Filter block uses an FFT to implement the overlap-save method, a technique that combines successive frequency-domain filtered sections of an input sequence. Implement the overlap-save method of frequency-domain filtering. Valid inputs to this block are 1-D vectors, sample-based vectors, frame-based vectors, and frame-based full matrices.
Overlap-Save FFT Filter The circular convolution of each section is computed by multiplying the FFTs of the input section and filter coefficients, and computing the inverse FFT of the product. y = ifft(fft(u(i:i+(L-1)),nfft) .* fft(b,nfft)) where nfft is specified by the FFT size parameter as a power-of-two value greater (typically much greater) than n+1. Values for FFT size that are not powers of two are rounded upwards to the nearest power-of-two value to obtain nfft.
Overlap-Save FFT Filter FFT size The size of the FFT, which should be a power-of-two value greater than the length of the specified FIR filter. FIR coefficients The filter numerator coefficients. Output The complexity of the output; Real or Complex. If the input signal or the filter coefficients are complex, this should be set to Complex. References Oppenheim, A. V. and R. W. Schafer. Discrete-Time Signal Processing. Englewood Cliffs, NJ: Prentice Hall, 1989. Proakis, J. and D. Manolakis.
Pad Purpose 5Pad Library Signal Operations Description The Pad block changes the size of the input matrix from Mi-by-Ni to Mo-by-No by padding or truncating along the rows, the columns, or both dimensions. The dimensions of the output, Mo and No, are specified by the Number of output rows and Number of output columns parameters, respectively. The value with which to pad the input is set by the Value parameter. Alter the input size by padding or truncating rows and/or columns.
Pad Number of output rows The desired number of rows in the output, Mo. This parameter is enabled when Columns or Columns and rows is selected in the Pad along menu. Number of output columns The desired number of columns in the output, No. This parameter is enabled when Rows or Columns and rows is selected in the Pad along menu.
Permute Matrix Purpose 5Permute Matrix Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Permute Matrix block reorders the rows or columns of M-by-N input matrix A as specified by indexing input P. Reorder the rows or columns of a matrix. When the Permute parameter is set to Rows, the block uses the rows of A to create a new matrix with the same column dimension.
Permute Matrix When length of the permutation vector P is not equal to the number of rows or columns of the input matrix A, you can choose to get an error dialog box and terminate the simulation by checking Error when length of P is not equal to Permute dimension size. If input A is frame-based, the output is frame-based; otherwise, the output is sample-based.
Permute Matrix Dialog Box Permute Method of constructing the output matrix; by permuting rows or columns of the input. Invalid permutation index Response to an invalid index value. Tunable, except in Simulink’s external mode. Error when length of P is not equal to Permute dimension size Option to display an error dialog box and terminate the simulation if the length of the permutation vector P is not equal to the number of rows or columns of the input matrix A.
Permute Matrix See “Reordering Channels in a Frame-Based Multichannel Signal” on page 3-61 for related information.
Polynomial Evaluation Purpose 5Polynomial Evaluation Library Math Functions / Polynomial Functions Description The Polynomial Evaluation block applies a polynomial function to the real or complex input at the In port. Evaluate a polynomial expression. y = polyval(u) % Equivalent MATLAB code The Polynomial Evaluation block performs these types of operation more efficiently than the equivalent construction using Simulink Sum and Math Function blocks.
Polynomial Evaluation Dialog Box Use constant coefficients When selected, enables the Constant coefficients parameter and disables the Coeffs input port. Constant coefficients The vector of polynomial coefficients to apply to the input, in order of descending exponents. This parameter is enabled when the Use constant coefficients check box is selected.
Polynomial Stability Test Purpose 5Polynomial Stability Test Library Math Functions / Polynomial Functions Description The Polynomial Stability Test block uses the Schur-Cohn algorithm to determine whether all roots of a polynomial are within the unit circle. Determine whether all roots of the input polynomial are inside the unit circle using the Schur-Cohn algorithm.
Polynomial Stability Test typical in DSP applications, the transfer function above is specified in descending powers of z-1 rather than z.
Pseudoinverse Purpose 5Pseudoinverse Library Math Functions / Matrices and Linear Algebra / Matrix Inverses Description The Pseudoinverse block computes the Moore-Penrose pseudoinverse of input matrix A. Compute the Moore-Penrose pseudoinverse of a matrix. [U,S,V] = svd(A,0) % Equivalent MATLAB code The pseudoinverse of A is the matrix A+ such that A + + = VS U * where U and V are orthogonal matrices, and S is a diagonal matrix.
Pseudoinverse See Also Cholesky Inverse LDL Inverse LU Inverse Singular Value Decomposition inv DSP Blockset DSP Blockset DSP Blockset DSP Blockset MATLAB See “Inverting Matrices” on page 4-19 for related information.
QR Factorization Purpose 5QR Factorization Library Math Functions / Matrices and Linear Algebra / Matrix Factorizations Description The QR Factorization block uses modified Gram-Schmidt iteration to factor a column permutation of the M-by-N input matrix A as Factor a rectangular matrix into unitary and upper triangular components. A e = QR where Q is an M-by-min(M,N) unitary matrix, and R is a min(M,N)-by-N upper-triangular matrix.
QR Factorization – 0.105 – 0.986 – 0.131 0.843 – 0.159 0.514 – 0.527 – 0.057 0.848 9.487 – 2.846 – 8.117 0 – 8.826 – 1.575 0 0 3.105 9 –1 2 –1 8 –5 2 –5 7 (2 1 3) –1 9 2 A = 8 –1 –5 e –5 2 7 Dialog Box References Golub, G. H., and C. F. Van Loan. Matrix Computations. 3rd ed. Baltimore, MD: Johns Hopkins University Press, 1996.
QR Solver Purpose 5QR Solver Library Math Functions / Matrices and Linear Algebra / Linear System Solvers Description The QR Solver block solves the linear system AX=B, which can be overdetermined, underdetermined, or exactly determined. The system is solved by applying QR factorization to the M-by-N matrix, A, at the A port. The input to the B port is the right-hand-side M-by-L matrix, B. A length-M 1-D vector input at either port is treated as an M-by-1 matrix.
QR Solver is solved for X by noting that Q-1 = Q* and substituting Y = Q*Be. This requires computing a matrix multiplication for Y and solving a triangular system for X. RX = Y Dialog Box Supported Data Types Double-precision floating point See Also Levinson-Durbin LDL Solver LU Solver QR Factorization SVD Solver DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset See “Solving Linear Systems” on page 4-16 for related information.
Queue Purpose 5Queue Library Signal Management / Buffers Description The Queue block stores a sequence of input samples in a FIFO (first in, first out) register. The register capacity is set by the Register size parameter, and inputs can be scalars, vectors, or matrices. Store inputs in a FIFO register. The block pushes the input at the In port onto the end of the queue when a trigger event is received at the Push port.
Queue the Queue block is reenabled; the Out port value is only reset to zero in this case if Clear output port on reset is selected.
Queue Examples Example 1 The table below illustrates the Queue block’s operation for a Register size of 4, Trigger type of Either edge, and Clear output port on reset enabled. Because the block triggers on both rising and falling edges in this example, each transition from 1 to 0 or 0 to 1 in the Push, Pop, and Clr columns below represents a distinct trigger event. A 1 in the Empty column indicates an empty queue, while a 1 in the Full column indicates a full queue.
Queue Dialog Box Register size The number of entries that the FIFO register can hold. Trigger type The type of event that triggers the block’s execution. Tunable. Push onto full register Response to a trigger received at the Push port when the register is full. Pop empty register Response to a trigger received at the Pop port when the register is empty. Tunable. Empty register output Enable the Empty output port, which is high (1) when the queue is empty, and low (0) otherwise.
Queue Clear input Enable the Clr input port, which empties the queue when the trigger specified by the Trigger type is received. Clear output port on reset Reset the Out port to zero (in addition to clearing the queue) when a trigger is received at the Clr input port. Tunable.
Random Source Purpose 5Random Source Library DSP Sources Description The Random Source block generates a frame of M values drawn from a uniform or Gaussian pseudorandom distribution, where M is specified by the Samples per frame parameter. Generate randomly distributed values.
Random Source Variance parameters generates an N-channel output (M-by-N frame matrix) containing a distinct random distribution in each column. When only one of these parameters is specified as a vector, the other is scalar expanded to the same length. Output Data Type The block’s output can be either real or complex, as selected by the Real and Complex options in the Output complexity parameter.
Random Source The specified variance is equally divided between the real and imaginary components, so that 2 2 σ σ Re = -----2 2 2 σ σ Im = -----2 Output Repeatability The Repeatability parameter determines whether or not the block outputs the same signal each time you run the simulation. You can set the parameter to one of the following options: • Repeatable — The block outputs the same signal each time you run the simulation.
Random Source a five-channel output is equivalent to specifying an Initial seed vector of [10 12 14 16 18]. For complex outputs (Output complexity parameter set to Complex), a length-N seed vector can be specified to set a distinct initial generator seed to be used for the real components of each individual channel. The block increments these values by 1 to determine the initial seeds used for the imaginary components of the corresponding channels.
Random Source Dialog Box Source type The distribution from which to draw the random values, Uniform or Gaussian. Minimum The minimum value in the uniform distribution. This parameter is only enabled when Uniform is selected from the Source type parameter. Tunable.
Random Source Maximum The maximum value in the uniform distribution. This parameter is only enabled when Uniform is selected from the Source type parameter. Tunable. Mean The mean of the Gaussian (normal) distribution. This parameter is only enabled when Gaussian is selected from the Source type parameter. Tunable. Variance The variance of the Gaussian (normal) distribution. This parameter is only enabled when Gaussian is selected from the Source type parameter. Tunable.
Random Source Sample time The sample period, Ts, of the random output sequence. The output frame period is M∗Ts. This parameter is enabled when the Inherit output port attributes check box is deselected. Samples per frame The number of samples, M, in each output frame. This parameter is enabled when the Inherit output port attributes check box is deselected. Output complexity The data type of the output, Real or Complex.
Real Cepstrum Purpose 5Real Cepstrum Library Transforms Description The Real Cepstrum block computes the real cepstrum of each channel in the real-valued M-by-N input matrix, u. For both sample-based and frame-based inputs, the block assumes that each input column is a frame containing M consecutive samples from an independent channel. The block does not accept complex-valued inputs. Compute the real cepstrum of an input.
Real Cepstrum Inherit FFT length from input port dimensions When selected, matches the output frame size to the input frame size. FFT length The number of frequency points at which to compute the FFT, which is also the output frame size, Mo. This parameter is available when Inherit FFT length from input port dimensions is not selected.
Reciprocal Condition Purpose 5Reciprocal Condition Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Reciprocal Condition block computes the reciprocal of the condition number for a square input matrix A. Compute the reciprocal condition of a square matrix in the 1-norm. y = rcond(A) % Equivalent MATLAB code or 1 1 y = --- = ------------------------------–1 κ A 1 A 1 where κ is the condition number (κ ≥ 1), and y is the scalar sample-based output (0 ≤ y < 1).
Reciprocal Condition Dialog Box References Golub, G. H., and C. F. Van Loan. Matrix Computations. 3rd ed. Baltimore, MD: Johns Hopkins University Press, 1996.
Repeat Purpose 5Repeat Library Signal Operations Description The Repeat block upsamples each channel of the Mi-by-N input to a rate L times higher than the input sample rate by repeating each consecutive input sample L times at the output. The integer L is specified by the Repetition count parameter. Resample an input at a higher rate by repeating values.
Repeat • Maintain input frame rate The block generates the output at the faster (upsampled) rate by using a proportionally larger frame size than the input. For L repetitions of the input, the output frame size is L times larger than the input frame size (Mo = Mi∗L), but the input and output frame rates are equal. The model below shows a single-channel input of frame size 16 being upsampled through 4-times repetition to a frame size of 64. The input and output frame rates are identical.
Repeat The block also has zero latency for all multirate operations in Simulink’s single-tasking mode. Zero tasking latency means that the block repeats the first input (received at t=0) for the first L output samples, the second input for the next L output samples, and so on. The Initial condition parameter value is not used. Nonzero Latency.
Repeat output frame period of 1 (0.25∗4). The first channel should contain the positive ramp signal 1, 2, ..., 100, and the second channel should contain the negative ramp signal -1, -2, ..., -100. - Signal = [(1:100)' (-1:-1:-100)'] - Sample time = 0.25 - Samples per frame = 4 • Configure the Repeat block to upsample the two-channel input by increasing the output frame rate by a factor of 2 relative to the input frame rate.
Repeat 14 1 1 2 2 3 3 4 4 5 5 -14 -1 -1 -2 -2 -3 -3 -4 -4 -5 -5 Since we ran this frame-based multirate model in multitasking mode, the block repeats each row of the initial condition matrix for L output samples, where L is the Repetition count of 2. The first row of the first input matrix appears in the output as sample 9 (i.e., sample MiL+1, where Mi is the input frame size). Dialog Box Repetition count The integer number of times, L, that the input value is repeated at the output.
Repeat Frame-based mode For frame-based operation, the method by which to implement the repetition (upsampling): Maintain input frame size (i.e., increase the frame rate), or Maintain input frame rate (i.e., increase the frame size). The Frame-based mode parameter must be set to Maintain input frame size for sample-base inputs. Tunable.
RLS Adaptive Filter Purpose 5RLS Adaptive Filter Library Filtering / Adaptive Filters Description The RLS Adaptive Filter block recursively computes the least squares estimate (RLS) of the FIR filter coefficients. Compute filter estimates for an input using the RLS adaptive filter algorithm.
RLS Adaptive Filter The block icon has port labels corresponding to the inputs and outputs of the RLS algorithm. Note that inputs to the In and Err ports must be sample-based scalars. The signal at the Out port is a scalar, while the signal at the Taps port is a sample-based vector.
RLS Adaptive Filter Dialog Box FIR filter length The length of the FIR filter. Memory weighting factor The exponential weighting factor, in the range [0,1]. A value of 1 specifies an infinite memory. Tunable. Initial value of filter taps The initial FIR filter coefficients. Initial input variance estimate The initial value of 1/P(n). Adapt input Enables the Adapt port. References Haykin, S. Adaptive Filter Theory. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1996.
RLS Adaptive Filter See “Adaptive Filters” on page 4-3 for related information.
RMS Purpose 5RMS Library Statistics Description The RMS block computes the RMS value of each column in the input, or tracks the RMS value of a sequence of inputs over a period of time. The Running RMS parameter selects between basic operation and running operation. Compute the root-mean-square (RMS) value of an input or sequence of inputs.
RMS parameter to None.) For sample-based inputs, the running RMS for each channel is initialized to the value in the corresponding channel of the current input. For frame-based inputs, the running RMS for each channel is initialized to the earliest value in each channel of the current input. As in basic operation, length-M 1-D vector inputs and sample-based length-M row vector inputs are both treated as M-by-1 column vectors.
RMS In ch1 Simulation time First input Output Rst ch2 ch1 61 13 39 t=0 0 –7 2 2 4 5 1 t=1 0 8 6 0 2 –1 5 t=2 1 –3 0 2 4 1 17 t=3 0 First output ch2 6.00 1.00 4.30 2.24 3.92 5.51 4.87 4.87 4.45 4.71 4.55 4.32 Reset 8.00 6.00 5.66 4.47 4.65 4.65 4.30 4.03 3.95 4.02 3.63 7.85 Dialog Box Running RMS Enables running operation when selected. Reset port Enables the Rst input port when set to Non-zero sample, and disables the Rst input port when set to None.
RMS See Also 5-382 Mean Variance DSP Blockset DSP Blockset
Sample and Hold Purpose 5Sample and Hold Library Signal Operations Description The Sample and Hold block acquires the input at the signal port whenever it receives a trigger event at the trigger port (marked by ). The block then holds the output at the acquired input value until the next triggering event occurs. If the acquired input is frame-based, the output is frame-based; otherwise, the output is sample-based. Sample and hold an input signal.
Sample and Hold Initial condition The block’s output prior to the first trigger event.
Short-Time FFT Purpose 5Short-Time FFT Library Estimation / Power Spectrum Estimation Description The Short-Time FFT block computes a nonparametric estimate of the spectrum. The block averages the squared magnitude of the FFT computed over windowed sections of the input, and normalizes the spectral average by the square of the sum of the window samples. Compute a nonparametric estimate of the spectrum using the short-time, fast Fourier transform (ST-FFT) method.
Short-Time FFT Dialog Box Window type The type of window to apply. (See the Window Function block reference.) Tunable. Stopband attenuation in dB The level (dB) of stopband attenuation, Rs, for the Chebyshev window. Disabled for other Window type selections. Tunable. Beta The β parameter for the Kaiser window. Disabled for other Window type selections. Increasing Beta widens the mainlobe and decreases the amplitude of the window sidelobes in the window’s frequency magnitude response. Tunable.
Short-Time FFT parameter is enabled when Inherit FFT length from input dimensions is not selected. Number of spectral averages The number of spectra to average; setting this parameter to 1 effectively disables averaging. References Oppenheim, A. V. and R. W. Schafer. Discrete-Time Signal Processing. Englewood Cliffs, NJ: Prentice Hall, 1989. Proakis, J. and D. Manolakis. Digital Signal Processing. 3rd ed. Englewood Cliffs, NJ: Prentice-Hall, 1996.
Signal From Workspace Purpose 5Signal From Workspace Library DSP Sources Description The Signal From Workspace block imports a signal from the MATLAB workspace into the Simulink model. The Signal parameter specifies the name of a MATLAB workspace variable containing the signal to import, or any valid MATLAB expression defining a matrix or 3-D array. Import a signal from the MATLAB workspace.
Signal From Workspace • If Cyclic Repetition is specified, the block repeats the signal from the beginning after generating the last frame. If there are not enough samples at the end of the signal to fill the final frame, the block zero-pads the final frame as necessary to ensure that the output for each cycle is identical (e.g., the ith frame of one cycle contains the same samples as the ith frame of any other cycle).
Signal From Workspace MATLAB Workspace Matrix output, frame period = T s A ( :, :, 1 ) = 1 1 11 A ( :, :, 2 ) = 2 2 22 A ( :, :, 3 ) = 3 3 33 00 00 33 33 22 22 11 11 t=3 t=2 t=1 t=0 (Ts=1, Mo=1) first matrix output The Samples per frame parameter is set to 1 for 3-D input. Dialog Box Signal The name of the MATLAB workspace variable from which to import the signal, or a valid MATLAB expression specifying the signal. Sample time The sample period, Ts, of the output.
Signal From Workspace Form output after final data value by Specifies the output after all of the specified signal samples have been generated. The block can output zeros for the duration of the simulation (Setting to zero), repeat the final data sample (Holding Final Value) or repeat the entire signal from the beginning (Cyclic Repetition). Tunable. Supported Data Types (MATLAB commands for casting values to certain data types are provided in parentheses.
Signal To Workspace Purpose 5Signal To Workspace Library DSP Sinks Description The Signal To Workspace block writes data from your simulation into an array in MATLAB’s main workspace. The output array can be 2-D or 3-D, depending on whether the data is 1-D, sample-based, or frame-based. The Signal To Workspace block and Simulink’s To Workspace block can output the same arrays if their parameters are set appropriately. Write simulation data to an array in MATLAB’s main workspace.
Signal To Workspace The Frames parameter sets the dimension of the output array to 2-D or 3-D for frame-based inputs. The block ignores this parameter for 1-D and sample-based inputs. The Frames parameter has the following two settings: • Log frames separately (3-D array): Given an M-by-N frame-based input signal, the block outputs an M-by-N-by-K array, where K is the number of frames logged by the end of the simulation. (K is bounded above by the Limit data points to last parameter.
Signal To Workspace Input Signal Type Signal To Workspace Output Dimension Frame-based M-by-N matrix; Frame set to Log frames separately (3-D array) M-by-N-by-K array Frame-based M-by-N matrix; Frame set to Concatenate frames (2-D array) (K∗f)-by-N matrix K∗f is the number of samples acquired by the end of the simulation.
Signal To Workspace MATLAB Workspace 2-by-2 sample-based input 11 1 – 11 0 ... t=10 . . . t=2 2 1 –2 0 1 1 –1 0 t=1 t=0 First Sample Sample 1 1 1 –1 0 A ( :, :, 2 ) = 2 1 –2 0 A ( :, :, 3 ) = 3 1 –3 0 … Last Sample Sample 11 3 1 –3 0 A ( :, :, 1 ) = A ( :, :, 11 ) = 11 1 – 11 0 The Example 1 block settings are as follows.
Signal To Workspace frames (two samples per frame) by the end of the simulation. The frames are concatenated to create a 22-by-4 matrix, A, in the MATLAB workspace. The block settings for the following Example 2 model are similar to the Example 1 block settings, except Frames is set to Concatenate frames (2-D array) and the Signal From Workspace parameter, Signal, is set to input2, where input2 = [1 -1 1 0; 2 -2 1 0; 3 -3 1 0;...
Signal To Workspace Dialog Box Variable name The name of the array that holds the input data. Tunable. Limit data points to last The maximum number of input samples (for sample-based inputs) or input frames (for frame-based inputs) to be saved. Tunable. Decimation The decimation factor, d. Data is written at every dth sample. Tunable. Frames The output dimensionality for frame-based inputs. Frames can be set to Concatenate frames (2-D array) or Log frames separately (3-D array).
Sine Wave Purpose 5Sine Wave Library DSP Sources Description The Sine Wave block generates a multichannel real or complex sinusoidal signal, with independent amplitude, frequency, and phase in each output channel. A real sinusoidal signal is generated when the Output complexity parameter is set to Real, and is defined by an expression of the type Generate a continuous or discrete sine wave.
Sine Wave sin ( 2000πt ) y = 2 sin ( 1000πt ) 3 sin 500πt + --π- 2 ( channel 1 ) ( channel 2 ) ( channel 3 ) In all discrete modes (see below), the block buffers the sampled sinusoids into frames of size M, where M is specified by the Samples per frame parameter. The output is a frame-based M-by-N matrix with frame period M∗Ts, where Ts is specified by the Sample time parameter. For M=1, the output is sample-based.
Sine Wave • Discrete In discrete mode, the block’s discrete-time output can be generated by directly evaluating the trigonometric function, by table look-up, or by a differential method. The three options are explained below. Discrete Computational Methods When Discrete is selected from the Sample mode parameter, the secondary Computation method parameter provides three options for generating the discrete sinusoid: • Trigonometric Fcn • Table Lookup • Differential Trigonometric Fcn.
Sine Wave Table Lookup. The table look-up method precomputes the unique samples of every output sinusoid at the start of the simulation, and recalls the samples from memory as needed. Because a table of finite length can only be constructed if all output sequences repeat, the method requires that the period of every sinusoid in the output be evenly divisible by the sample period. That is, 1/(fiTs) = ki must be an integer value for every channel i = 1, 2, ..., N.
Sine Wave This mode offers reduced computational load, but is subject to drift over time due to cumulative quantization error. Because the method is not contingent on an absolute time value, there is no danger of discontinuity during extended operations (when an absolute time variable might overflow). Examples The dspsinecomp demo provides a comparison of all the available sine generation methods.
Sine Wave length must be the same as that specified for the Frequency and Phase parameters. Tunable; the amplitude values can be altered while a simulation is running, but the vector length must remain the same. Frequency A length-N vector containing the frequencies, in rad/s, of the sine waves in each of N output channels, or a scalar to be applied to all N channels. The vector length must be the same as that specified for the Amplitude and Phase parameters.
Sine Wave Sample time The period with which the sine wave is sampled, Ts. The block’s output frame period is M∗Ts, where M is specified by the Samples per frame parameter. This parameter is disabled when Continuous is selected from the Sample mode parameter. Samples per frame The number of consecutive samples from each sinusoid to buffer into the output frame, M. This parameter is disabled when Continuous is selected from the Sample mode parameter.
Singular Value Decomposition Purpose 5Singular Value Decomposition Library Math Functions / Matrices and Linear Algebra / Matrix Factorizations Description The Singular Value Decomposition block factors the M-by-N input matrix A such that Factor a matrix using singular value decomposition. A = U∗ diag ( S ) ⋅ V T where U is an M-by-P matrix, V is an N-by-P matrix, S is a length-P vector, and P is defined as min(M,N). When M = N, U and V are both M-by-M unitary matrices.
Singular Value Decomposition References Golub, G. H., and C. F. Van Loan. Matrix Computations. 3rd ed. Baltimore, MD: Johns Hopkins University Press, 1996. Supported Data Types Double-precision floating point See Also Autocorrelation LPC Cholesky Factorization LDL Factorization LU Inverse Pseudoinverse QR Factorization SVD Solver svd DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset MATLAB See “Factoring Matrices” on page 4-17 for related information.
Sort Purpose 5Sort Library Statistics Description The Sort block sorts the elements in each column of the input using a Quicksort algorithm. The Mode parameter specifies the block’s mode of operation, and can be set to Value, Index, or Value and Index. Sort the elements in the input by value. Value Mode When Mode is set to Value, the block sorts the elements in each column of the M-by-N input matrix u in order of ascending or descending value, as specified by the Sort order parameter.
Sort Value and Index Mode When Mode is set to Value and Index, the block outputs both the sorted matrix, val, and the index matrix, idx. Dialog Box Mode The block’s mode of operation: Output the sorted matrix (Value), the index matrix (Index), or both (Value and Index). Sort order The order in which to sort the input values, Descending or Ascending. Tunable, except in Simulink’s external mode.
Spectrum Scope Purpose 5Spectrum Scope Library DSP Sinks Description The Spectrum Scope block computes and displays the magnitude-squared FFT of the input. The input be a 1-D vector or a 2-D matrix of any frame status. Compute and display the short-time FFT of each input signal. When the input is a 1-by-N sample-based vector or M-by-N sample-based matrix, you must select the Buffer input check box.
Spectrum Scope the number of samples on which to perform the FFT. The block zero pads or truncates every channel’s buffer to Nfft before computing the FFT. The number of spectra to average is set by the Number of spectral averages parameter. Setting this parameter to 1 effectively disables averaging; See Short-Time FFT for more information. In order to correctly scale the frequency axis (i.e.
Spectrum Scope For information about the scope window, as well as the Display properties, Axis properties, and Line properties panels in the dialog box, see the reference page for the Vector Scope block. Dialog Box Scope properties Select to expose Scope properties panel. Tunable. Buffer input Select to expose Buffer input panel. Tunable. Buffer size The number of signal samples to include in each buffer. Tunable. Buffer overlap The number of samples by which consecutive buffers overlap. Tunable.
Spectrum Scope FFT length The number of samples on which to perform the FFT. If the FFT length differs from the buffer size, the data is zero-padded or truncated as needed. Tunable. Number of spectral averages The the number of spectra to average. Setting this parameter to 1 effectively disables averaging. See Short-Time FFT for more information. Tunable. Display properties Select to expose the Display properties panel. See Vector Scope for more information. Tunable.
Stack Purpose 5Stack Library Signal Management / Buffers Description The Stack block stores a sequence of input samples in a LIFO (last in, first out) register. The register capacity is set by the Stack depth parameter, and inputs can be scalars, vectors, or matrices. Store inputs into a LIFO register. The block pushes the input at the In port onto the top of the stack when a trigger event is received at the Push port.
Stack When two or more of the control input ports are triggered at the same time step, the operations are executed in the following order: 1 Clr 2 Push 3 Pop The triggering event for the Push, Pop, and Clr ports is specified by the Trigger type pop-up menu, and can be one of the following: • Rising edge triggers execution of the block when the trigger input rises from a negative value to zero or a positive value, or from zero to a positive value.
Stack represents a distinct trigger event. A 1 in the Empty column indicates an empty buffer, while a 1 in the Full column indicates a full buffer.
Stack Dialog Box Stack depth The number of entries that the LIFO register can hold. Trigger type The type of event that triggers the block’s execution. Tunable. Push full stack Response to a trigger received at the Push port when the register is full. Pop empty stack Response to a trigger received at the Pop port when the register is empty. Tunable. Empty stack output Enable the Empty output port, which is high (1) when the stack is empty, and low (0) otherwise.
Stack Clear input Enable the Clr input port, which empties the stack when the trigger specified by the Trigger type is received. Clear output port on reset Reset the Out port to zero (in addition to clearing the stack) when a trigger is received at the Clr input port. Tunable.
Standard Deviation Purpose 5Standard Deviation Library Statistics Description The Standard Deviation block computes the standard deviation of each column in the input, or tracks the standard deviation of a sequence of inputs over a period of time. The Running standard deviation parameter selects between basic operation and running operation. Find the standard deviation of an input or sequence of inputs.
Standard Deviation Running Operation When the Running standard deviation check box is selected, the block tracks the standard deviation of each channel in a time-sequence of M-by-N inputs. For sample-based inputs, the output is a sample-based M-by-N matrix with each element yij containing the standard deviation of element uij over all inputs since the last reset.
Standard Deviation where u = [6 1 3 -7 2 5 8 0 -1 -3 2 1;1 3 9 2 4 1 6 2 5 0 4 17]' The Discrete Impulse block has the following settings: • Delay (samples) = 2 • Sample time = 1 • Samples per frame = 1 The block’s operation is shown in the figure below. In ch1 Simulation time First input 5-420 Output Rst ch1 ch2 61 13 39 t=0 0 –7 2 2 4 5 1 t=1 0 8 6 0 2 –1 5 t=2 1 –3 0 2 4 1 17 t=3 0 First output ch2 0 0 3.54 1.41 2.52 4.16 5.56 3.59 4.85 3.11 4.63 3.01 Reset 0 0 5.66 2.83 4.93 2.
Standard Deviation Dialog Box Running standard deviation Enables running operation when selected. Reset port Enables the Rst input port when set to Non-zero sample, and disables the Rst input port when set to None.
Submatrix Purpose 5Submatrix Library Math Functions / Matrices and Linear Algebra / Matrix Operations, Signal Management / Indexing Description The Submatrix block extracts a contiguous submatrix from the M-by-N input matrix u. A length-M 1-D vector input is treated as an M-by-1 matrix. The Row span parameter provides three options for specifying the range of rows in u to be retained in submatrix output y: Select a subset of elements (submatrix) from a matrix input.
Submatrix The Row, Column, Starting row or Starting column can be specified in six ways: • First For rows, this specifies that the first row of u should be used as the first row of y. If all columns are to be included, this is equivalent to y(1,:) = u(1,:). For columns, this specifies that the first column of u should be used as the first column of y. If all rows are to be included, this is equivalent to y(:,1) = u(:,1).
Submatrix columns are to be included, this is equivalent to y(1,:) = u(M/2-firstrow,:). For columns, this specifies that the column of u offset from column N/2 by the Starting column offset parameter, firstcol, should be used as the first column of y. If all rows are to be included, this is equivalent to y(:,1) = u(:,N/2-firstcol). • Middle For rows, this specifies that the middle row of u should be used as the only row of y. If all columns are to be included, this is equivalent to y = u(M/2,:).
Submatrix • Last For rows, this specifies that the last row of u should be used as the last row of y. If all columns are to be included, this is equivalent to y(end,:) = u(M,:). For columns, this specifies that the last column of u should be used as the last column of y. If all rows are to be included, this is equivalent to y(:,end) = u(:,N). • Offset from middle For rows, this specifies that the row of u offset from row M/2 by the Ending row offset parameter, lastrow, should be used as the last row of y.
Submatrix The figure below shows the operation for a 5-by-7 matrix with random integer elements, randint(5,7,10). 8 2 5 4 8 6 4 0 7 4 5 7 8 6 1 3 8 8 3 8 0 3 7 0 1 1 6 2 4 1 6 3 7 7 5 2 7 4 7 1 5 There are often several possible parameter combinations that select the same submatrix from the input.
Submatrix Row span The range of input rows to be retained in the output. Options are All rows, One row, or Range of rows. Row/Starting row The input row to be used as the first row of the output. Row is enabled when One row is selected from Row span, and Starting row when Range of rows is selected from Row span. Row index/Starting row index The index of the input row to be used as the first row of the output.
Submatrix Column/Starting column The input column to be used as the first column of the output. Column is enabled when One column is selected from Column span, and Starting column is enabled when Range of columns is selected from Column span. Column index/Starting column index The index of the input column to be used as the first column of the output. Column index is enabled when Index is selected from Column, and Starting column index is enabled when Index is selected from Starting column.
Submatrix See Also Reshape Selector Variable Selector reshape Simulink Simulink DSP Blockset MATLAB See “Deconstructing Signals” on page 3-54 for related information.
SVD Solver Purpose 5SVD Solver Library Math Functions / Matrices and Linear Algebra / Linear System Solvers Description The SVD Solver block solves the linear system AX=B, which can be overdetermined, underdetermined, or exactly determined. The system is solved by applying SVD factorization to the M-by-N matrix, A, at the A port. The input to the B port is the right hand-side M-by-L matrix, B. A length-M 1-D vector input at either port is treated as an M-by-1 matrix.
SVD Solver See Also Autocorrelation LPC Cholesky Solver LDL Solver Levinson-Durbin LU Inverse Pseudoinverse QR Solver Singular Value Decomposition DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset See “Solving Linear Systems” on page 4-16 for related information.
Time Scope 5Time Scope The Time Scope block is the same as the Scope block in Simulink. To learn how to use the Time Scope block, see the Scope block reference page in the Simulink documentation.
Time-Varying Direct-Form II Transpose Filter Purpose 5Time-Varying Direct-Form II Transpose Filter Library Filtering / Filter Designs Description The Time-Varying Direct-Form II Transpose Filter block is a version of the Direct-Form II Transpose Filter block whose filter coefficients can be updated during the simulation. The block applies a direct-form II transposed IIR filter to the top input (In). Apply a variable IIR filter to the input. ... x( k) b( m) Σ -a(n) zn-1(k) b(3) z-1 ...
Time-Varying Direct-Form II Transpose Filter • Pole-zero The block accepts inputs for both the numerator (Num) and denominator (Den) vectors. Input Num is a vector of numerator coefficients, [b(1) b(2) ... b(m)] and input Den is a vector of denominator coefficients, [a(1) a(2) ... a(n)] • All-zero The block accepts only the numerator vector (Num). The denominator of the all-zero filter is 1. • All-pole The block accepts only the denominator vector (Den). The numerator of the all-pole filter is 1.
Time-Varying Direct-Form II Transpose Filter • Vector The vector has a length equal to the number of delay elements in each filter channel, max(m,n)-1, and specifies a unique initial condition for each delay element in the filter channel. This vector of initial conditions is applied to each filter channel. • Matrix The matrix specifies a unique initial condition for each delay element, and can specify different initial conditions for each filter channel.
Time-Varying Direct-Form II Transpose Filter Dialog Box Filter type The type of filter to apply: Pole-Zero (IIR), All-Zero (FIR), or All-Pole (AR). The Num and Den input ports are enabled or disabled as appropriate. Initial conditions The filter’s initial conditions, a scalar, vector, or matrix. Support non-normalized filters Normalizes the filter by a1 when selected. Filter update rate The frequency with which the block updates the filter coefficients; once per sample, or once per frame.
Time-Varying Direct-Form II Transpose Filter See Also Discrete Filter Filter Realization Wizard Direct-Form II Transpose Filter Time-Varying Lattice Filter filter Simulink DSP Blockset DSP Blockset DSP Blockset MATLAB See “Designing Filters with Various Filter Structures” on page 4-6 for related information.
Time-Varying Lattice Filter Purpose 5Time-Varying Lattice Filter Library Filtering / Filter Designs Description The Time-Varying Lattice Filter block applies a moving average (MA) or autoregressive (AR) lattice filter to the top input (In). The filter reflection coefficients are specified by the vector input to the MA or AR port, and can vary with time. Apply a variable lattice filter to the input.
Time-Varying Lattice Filter The Initial conditions parameter may take one of four forms: • Empty matrix The empty matrix, [], causes a zero (0) initial condition to be applied to all delay elements in each filter channel. • Scalar The scalar value is copied to all delay elements in each filter channel. Note that a value of zero is equivalent to setting the Initial conditions parameter to the empty matrix.
Time-Varying Lattice Filter Dialog Box Filter type The type of filter to apply: MA or AR. The MA or AR input port is enabled or disabled appropriately. Initial conditions The filter’s initial conditions. Filter update rate The frequency with which the block updates the filter coefficients; once per sample, or once per frame. References Oppenheim, A. V. and R. W. Schafer. Discrete-Time Signal Processing. Englewood Cliffs, NJ: Prentice Hall, 1989. Proakis, J. and D. Manolakis. Digital Signal Processing.
Time-Varying Lattice Filter See “Designing Filters with Various Filter Structures” on page 4-6 for related information.
Toeplitz Purpose 5Toeplitz Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Toeplitz block generates a Toeplitz matrix from inputs defining the first column and first row. The top input (Col) is a vector containing the values to be placed in the first column of the matrix, and the bottom input (Row) is a vector containing the values to be placed in the first row of the matrix. Generate a matrix with Toeplitz symmetry.
Toeplitz 1 2 3 4 2 1 2 3 3 2 1 2 4 3 2 1 The output has the same frame status as the input. Dialog Box Symmetric When selected, enables the single-input configuration for symmetric Toeplitz matrix output.
To Wave Device Purpose 5To Wave Device Library DSP Sinks Description The To Wave Device block sends audio data to a standard Windows audio device in real-time. It is compatible with most popular Windows hardware, including Sound Blaster cards. (Models that contain both this block and the From Wave Device block require a duplex-capable sound card.
To Wave Device Buffering Because the audio device generates real-time audio output, Simulink must maintain a continuous flow of data to the device throughout the simulation. Delays in passing data to the audio hardware can result in hardware errors or distortion of the output. This means that the To Wave Device block must in principle supply data to the audio hardware as quickly as the hardware reads the data.
To Wave Device the hardware throughput rate is higher than the simulation throughput rate, and the buffer tends to empty over the duration of the simulation. Under normal operation, an empty buffer indicates that the simulation is finished, and the entire length of the audio signal has been processed. However, if the buffer size is too small in relation to the simulation throughput rate, the buffer may also empty before the entire length of signal is processed.
To Wave Device signal to be preloaded into the hardware buffer. A value of 0 for the Initial output delay parameter specifies the smallest possible initial delay, which is one frame. More general ways to improve throughput rates include simplifying the model, and running the simulation on a faster PC processor. See the Simulink documentation and “Delay and Latency” on page 3-85 for other ideas on improving simulation performance.
To Wave Device a value of 2 selects the second audio card, and so on. Select Use default audio device if the system has only a single audio card installed. Supported Data Types Double-precision floating point See Also From Wave Device To Wave File sound DSP Blockset DSP Blockset MATLAB See “Exporting and Playing WAV Files” on page 3-79 for related information.
To Wave File Purpose 5To Wave File Library DSP Sinks Description The To Wave File block writes audio data to a Microsoft Wave (.wav) file in the uncompressed PCM (pulse code modulation) format. For compatibility reasons, the sample rate of the discrete-time input signal should typically be one of the standard Windows audio device rates (8000, 11025, 22050, or 44100 Hz), although the block supports arbitrary rates. Write audio data to file in the Microsoft Wave (.wav) format (Windows only).
To Wave File Dialog Box File name The path and name of the file to write. Paths can be relative or absolute. Tunable. Sample width (bits) The number of bits used to represent each signal sample. Tunable. Minimum number of samples for each write to file The number of consecutive samples to write with each file access, L. Tunable.
Transpose Purpose 5Transpose Library Math Functions / Matrices and Linear Algebra / Matrix Operations Description The Transpose block transposes the M-by-N input matrix to size N-by-M. When the Hermitian check box is selected, the block performs the Hermitian (complex conjugate) transpose Compute the transpose of a matrix.
Transpose Supported Data Types Fixed-point Custom data types Boolean 8-, 16-, and 32-bit signed integer 8-, 16-, and 32-bit unsigned integer Single-precision floating point Double-precision floating point See Also Permute Matrix Reshape Submatrix 5-452 DSP Blockset Simulink DSP Blockset
Triggered Delay Line Purpose 5Triggered Delay Line Library Signal Management / Buffers Description The Triggered Delay Line block acquires a collection of Mo input samples into a frame, where Mo is specified by the Delay line size parameter. The block buffers a single sample from input 1 whenever it is triggered by the control signal at input 2 ( ).
Triggered Delay Line frame-based Mo-by-N matrix outputs, where Mo is the output frame size specified by the Delay line size parameter (i.e., the number of consecutive samples from the input frame to rebuffer into the output frame). Mo can be greater or less than the input frame size, Mi. Each of the N input channels is rebuffered independently. Initial Conditions The Triggered Delay Line block’s buffer is initialized to the value specified by the Initial condition parameter.
Triggered Delay Line Supported Data Types Fixed-point Custom data types Boolean 8-, 16-, and 32-bit signed integer 8-, 16-, and 32-bit unsigned integer Single-precision floating point Double-precision floating point See Also Buffer Delay Line Unbuffer DSP Blockset DSP Blockset DSP Blockset 5-455
Triggered Signal From Workspace Purpose 5Triggered Signal From Workspace Library DSP Sources Description The Triggered Signal From Workspace block imports signal samples from the MATLAB workspace into the Simulink model when triggered by the control signal at the input port ( ). The Signal parameter specifies the name of a MATLAB workspace variable containing the signal to import, or any valid MATLAB expression defining a matrix or 3-D array.
Triggered Signal From Workspace interpolation takes place). For single-channel signals, the Initial output parameter value can be a vector of length Mo or a scalar to repeat across the Mo elements of the initial output frames. For matrix outputs (Mo-by-N or M-by-N), the Initial output parameter value can be a vector of length N to repeat across all rows of the initial outputs, or a scalar to repeat across all elements of the initial matrix outputs.
Triggered Signal From Workspace Dialog Box Signal The name of the MATLAB workspace variable from which to import the signal, or a valid MATLAB expression specifying the signal. Trigger type The type of event that triggers the block’s execution. Tunable, except in Simulink’s external mode. Initial output The value to output until the first trigger event is received. Samples per frame The number of samples, Mo, to buffer into each output frame.
Triggered Signal From Workspace Supported Data Types (MATLAB commands for casting values to certain data types are provided in parentheses.
Triggered To Workspace Purpose 5Triggered To Workspace Library DSP Sinks Description The Triggered To Workspace block creates a matrix or array variable in the workspace, where it stores the acquired inputs at the end of a simulation. An existing variable with the same name is overwritten. Write the input sample to the workspace when triggered.
Triggered To Workspace Parameters dialog. You can access these parameters by selecting Parameters from the Simulation menu, and clicking on the Workspace I/O tab. The nontriggered version of this block is To Workspace. Dialog Box Trigger type The type of event that triggers the block’s execution. Tunable. Variable name The name of the workspace matrix in which to store the data. Maximum number of rows The maximum number of rows (one row per time step) to be saved, P. The default is 100 rows.
Triggered To Workspace See Also Signal From Workspace To Workspace DSP Blockset Simulink See “Exporting Signals” on page 3-72 for related information.
Unbuffer Purpose 5Unbuffer Library Signal Management / Buffers Description The Unbuffer block unbuffers an Mi-by-N frame-based input into a 1-by-N sample-based output. That is, inputs are unbuffered row-wise so that each matrix row becomes an independent time-sample in the output. The rate at which the block receives inputs is generally less than the rate at which the block produces outputs. Unbuffer a frame input to a sequence of scalar outputs.
Unbuffer ch2 ch1 t=6 ch3 ch4 ch2 ch1 7 0 0 –7 8 0 0 –8 9 0 1 –9 0000 ch3 ch4 t=0 0000 t=1 0000 t=2 1 0 1 –1 t=3 2 0 1 –2 t=4 3 0 0 –3 t=5 4 0 0 –4 t=6 5 0 1 –5 t=7 initial condition (multitasking delay) Tfi = 3 Frame-based input , t=3 frame period = T fi 4 0 0 –4 5 0 1 –5 6 0 1 –6 Sample-based output , sample period = Tfi/Mi t=0 1 0 1 –1 2 0 1 –2 3 0 0 –3 first matrix input Tso = Tsi = 1 Latency Zero Latency.
Unbuffer See “Excess Algorithmic Delay (Tasking Latency)” on page 3-91 and “The Simulation Parameters Dialog Box” in the Simulink documentation for more information about block rates and Simulink’s tasking modes. Dialog Box Initial conditions The value of the block’s initial output for cases of nonzero latency; a scalar, vector, or matrix.
Uniform Decoder Purpose 5Uniform Decoder Library Quantizers Description The Uniform Decoder block performs the inverse operation of the Uniform Encoder block, and reconstructs quantized floating-point values from encoded integer input. The block adheres to the definition for uniform decoding specified in ITU-T Recommendation G.701. Decode an integer input to a floating-point output.
Uniform Decoder Signed input values, u, greater than 2B-1-1 or less than -2B-1 are wrapped back into that range using mod-2B arithmetic. u = (mod(u+2^B/2,2^B)-(2^B/2)) % Equivalent MATLAB code The real and imaginary components of complex inputs wrap independently. The Output type parameter specifies whether the decoded floating-point output is single or double precision. Either level of output precision can be used with any of the six integer input data types.
Uniform Decoder Dialog Box Peak The largest amplitude represented in the encoded input. To correctly decode values encoded with the Uniform Encoder block, set the Peak parameters in both blocks to the same value. Bits The number of input bits, B, used to encode the data. (This can be less than the total number of bits supplied by the input data type.) To correctly decode values encoded with the Uniform Encoder block, set the Bits parameters in both blocks to the same value.
Uniform Decoder See Also Data Type Conversion Quantizer Uniform Encoder udecode uencode Simulink Simulink DSP Blockset Signal Processing Toolbox Signal Processing Toolbox 5-469
Uniform Encoder Purpose 5Uniform Encoder Library Quantizers Description The Uniform Encoder block performs the following two operations on each floating-point sample in the input vector or matrix: Quantize and encode a floating-point input to an integer output.
Uniform Encoder Inputs can be real or complex, double or single precision. The output data types that the block uses are shown in the table below. Note that most of the blocks in the DSP Blockset accept only double precision inputs. Use the Simulink Data Type Conversion block to convert integer data types to double precision. See “Working with Data Types” in the Simulink documentation for a complete discussion of data types, as well as a list of Simulink blocks capable of reduced-precision operations.
Uniform Encoder The real and complex components of each input (horizontal axis) are independently quantized to one of 23 distinct levels in the range [-2,1.5] and then mapped to one of 23 integer values in the range [0,7]. -2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 is mapped to is mapped to is mapped to is mapped to is mapped to is mapped to is mapped to is mapped to 0 1 2 3 4 5 6 7 The table below shows the results for a few particular inputs. Input Quantized Input Output 1.6 1.5+0.0i 7+4i -0.4 -0.5+0.
Uniform Encoder Dialog Box Peak The largest input amplitude to be encoded, V. Real or imaginary input values greater than (1-21-B)V or less than -V saturate (independently for complex inputs) at those limits. Bits The number of levels at which to quantize the floating-point input. (Also the number of bits needed to represent the integer output.) Output type The data type of the block’s output, Unsigned integer or Signed integer.
Unwrap Purpose 5Unwrap Library Signal Operations Description The Unwrap block unwraps each input channel by adding or subtracting appropriate multiples of 2π to each channel element. The input can be any matrix or 1-D vector, and must have radian phase entries. The block recognizes phase discontinuities larger than the Tolerance parameter setting. Unwrap the phase of a signal. The block preserves the input size, dimension, and frame status, and the output port rate equals the input port rate.
Unwrap The Two Unwrap Modes You must specify the unwrap mode by setting the parameter, Do not unwrap phase discontinuities between successive frames. The unwrap modes are summarized in the next table.
Unwrap Two Unwrap Modes In both unwrap modes, the block adds 2πk to each input channel’s elements, where it updates k at each phase discontinuity. (For more on the updating of k, see “Unwrap Method” on page 5-479.) The number of times that k is reset to 0 depends on the unwrap mode.
Unwrap The following diagrams illustrate how the two unwrap modes operate on various inputs. Default Unwrap Mode Operation: Frame-Based Inputs Sample-Based Inputs The block treats each input column as an independent channel. It unwraps by treating Channel 1 of Frame 2 as a continuation of Channel 1 of Frame 1. The block treats each element of the input matrix as an independent channel. (The first sample in Channel 1 is in the upper left corner of the Sample 1 matrix.
Unwrap Nondefault Unwrap Mode Operation: Frame-Based Inputs and Sample-Based (Nonrow) Inputs The block unwraps each column, treating each input matrix as completely unrelated to the other input matrices.
Unwrap Unwrap Method The Unwrap block unwraps each channel of its input matrix or input vector by adding 2πk to each successive channel element, and updating k at each phase jump. See the following steps to the unwrap method for details. Relevant Unwrap Terms: • ui — ith element of the input channel on which the algorithm operates • α — Tolerance parameter value • phase jump or phase discontinuity — difference between phase values of two adjacent channel entries that exceeds α .
Unwrap diagram. For more on phase unwrap, see the previous section, “Unwrap Method” on page 5-479.
Unwrap Unwrapping Phase Data Ranging Between π and -π Signal data with instantaneous phase values that range over all numbers Calculate Phases of Signal Data: Input: [ sin ( θ 0 ), sin ( θ 1 ), …, sin ( θ N ) ] 30 Output: [ θ ′0, θ ′1, …, θ ′N ] where sin ( θ ′n ) = sin ( θ n ) 25 20 and – π < θ ′n ≤ π 28π 6π 4π 2π [ sin ( 0 ), sin ------ , sin ------ , sin ------ , …, sin 15---------- ] 5 5 5 5 2pi 3pi 4pi Unwrap Restricted Phases: Input: [ θ ′0, θ ′1, …, θ ′N ] Output:
Unwrap Range of restricted phase data: – π < θ ′ ≤ π sin ( θ ′ ) 4π -----5 Large jump in phase value π ( –π ) – 4π ---------5 Limitations Dialog Box 5-482 2π -----5 θ′ – 2π ---------5 Range of unwrapped phase data: all numbers sin ( θ ) 4π 14π 24π ------, ----------, ----------, … 5 5 5 0 2π 12π 22π ------, ----------, ----------, … 5 5 5 θ cos ( θ ′ ) 6π 16π 26π ------, ----------, ----------, … 5 5 5 0, 2π, 4π, … cos ( θ ) 8π 18π 28π ------, ----------, ----------, … 5 5 5 The Unwrap block de
Unwrap Do not unwrap phase discontinuities between successive frames When this parameter is cleared, the block unwraps each input’s channels (the input channels are the columns of frame-based inputs and each element of sample-based inputs). When this parameter is set, the block unwraps each row of sample-based row vector inputs, and unwraps the columns of all other inputs, where each input matrix or input vector is treated as completely unrelated to the other input matrices or input vectors.
Upsample Purpose 5Upsample Library Signal Operations Description The Upsample block resamples each channel of the Mi-by-N input at a rate L times higher than the input sample rate by inserting L-1 zeros between consecutive samples. The integer L is specified by the Upsample factor parameter. The Sample offset parameter delays the output samples by an integer number of sample periods D, where 0 ≤ D < (L-1), so that any of the L possible output phases can be selected.
Upsample • Maintain input frame rate The block generates the output at the faster (upsampled) rate by using a proportionally larger frame size than the input. For upsampling by a factor of L, the output frame size is L times larger than the input frame size (Mo = Mi∗L), but the input and output frame rates are equal. The model below shows a single-channel input of frame size 16 being upsampled by a factor of 4 to a frame size of 64. The input and output frame rates are identical.
Upsample Latency and Initial Conditions Zero Latency. The Upsample block has zero tasking latency for all single-rate operations. The block is single-rate for the particular combinations of sampling mode and parameter settings shown in the table below. Sampling Mode Parameter Settings Sample-based Upsample factor parameter, L, is 1. Frame-based Upsample factor parameter, L, is 1, or Frame-based mode parameter is Maintain input frame rate.
Upsample See “Excess Algorithmic Delay (Tasking Latency)” on page 3-91 and “The Simulation Parameters Dialog Box” in the Simulink documentation for more information about block rates and Simulink’s tasking modes. Example Construct the frame-based model shown below. Adjust the block parameters as follows: • Configure the Signal From Workspace block to generate a two-channel signal with frame size of 4 and sample period of 0.25. This represents an output frame period of 1 (0.25∗4).
Upsample • Configure the Probe blocks by deselecting the Probe width and Probe complex signal check boxes (if desired). This model is multirate because there are at least two distinct frame rates, as shown by the two Probe blocks. To run this model in Simulink’s multitasking mode, select Fixed-step and discrete from the Type controls in the Solver panel of the Simulation Parameters dialog box, and select MultiTasking from the Mode parameter. Also set the Stop time to 30.
Upsample Dialog Box Upsample factor The integer factor, L, by which to increase the input sample rate. Sample offset The sample offset, D, which must be an integer in the range [0,L-1]. Initial condition The value with which the block is initialized for cases of nonzero latency, a scalar or matrix. This value (first row in frame-based mode) appears in the output as sample D+1. Frame-based mode For frame-based operation, the method by which to implement the upsampling: Maintain input frame size (i.e.
Upsample See Also 5-490 Downsample FIR Interpolation FIR Rate Conversion Repeat DSP Blockset DSP Blockset DSP Blockset DSP Blockset
Variable Fractional Delay Purpose 5Variable Fractional Delay Library Signal Operations Description The Variable Fractional Delay block delays each channel of the Mi-by-N input matrix, u, by a variable (possibly noninteger) number of sample intervals. Delay an input by a time-varying fractional number of sample periods.
Variable Fractional Delay The input to the Delay port, v, contains floating-point values in the range 0 ≤ v ≤ D specifying the number of sample intervals to delay the current input.
Variable Fractional Delay Delay values less than 0 are clipped to 0, and delay values greater than D are clipped to D, where D is the Maximum delay. Note that a delay value of 0 causes the block to pass through the current input sample, U(1), in the same simulation step that it is received. FIR Interpolation Mode.
Variable Fractional Delay For delay values less than P/2-1, the output is computed using linear interpolation. Delay values greater than D are clipped to D, where D is the Maximum delay. The block uses the intfilt function in the Signal Processing Toolbox to compute the FIR filters. Note When the Variable Fractional Delay block is used in a feedback loop, at least one block with nonzero delay (e.g., an Integer Delay block with Delay > 0) should be included in the loop as well.
Variable Fractional Delay Maximum delay The maximum delay that the block can produce, D. Delay input values exceeding this maximum are clipped at the maximum. Interpolation filter half-length Half the number of input samples to use in the FIR interpolation filter. Interpolation points per input sample The number of points per input sample, Q, at which a unique FIR interpolation filter is computed. Normalized input bandwidth The bandwidth to which the interpolated output samples should be constrained.
Variable Integer Delay Purpose 5Variable Integer Delay Library Signal Operations Description The Variable Integer Delay block delays the discrete-time input at the In port by the integer number of sample intervals specified by the input to the Delay port. The Delay port input rate must be an integer multiple of the In port input rate. The delay for a sample-based input sequence is a scalar value to uniformly delay every channel.
Variable Integer Delay The Variable Integer Delay block stores the D+1 most recent samples received at the In port for each channel. At each sample time the block outputs the stored sample(s) indexed by the input to the Delay port. For example, if the input to the In port, u, is a scalar signal, the block stores a vector, U, of the D+1 most recent signal samples.
Variable Integer Delay Integer Delay block does not have a fixed initial delay period during which the initial conditions appear at the output. Instead, the initial conditions are propagated to the output only when they are indexed in memory by the value at the Delay port. Both fixed and time-varying initial conditions can be specified in a variety of ways to suit the dimensions of the input sequence. Fixed Initial Conditions. The settings shown below specify fixed initial conditions.
Variable Integer Delay the block initializes U(2:6) with values [-1, -1, -1, 0, 1]. • Array of dimension M-by-N-by-D with which to initialize memory samples U(2:D+1), where D is the Maximum delay and M and N are the number of rows and columns, respectively, in the input matrix.
Variable Integer Delay sequence, the second sample in the current output frame is the input sample v(2) intervals earlier in the sequence, and so on. The illustration below shows how this works for an input with a sample period of 1 and frame size of 4. The Maximum delay (Dmax) is 5, and the Initial conditions parameter is set to -1. The delay input changes from [1 3 0 5] to [2 0 0 2] after the second input frame.
Variable Integer Delay Fixed Initial Conditions. The settings shown below specify fixed initial conditions. For a fixed initial condition, the block initializes each of D samples in memory to the value entered in the Initial conditions parameter. A fixed initial condition in frame-based mode can be one of the following: • Scalar value with which to initialize every sample of every channel in memory.
Variable Integer Delay –1 –2 –3 –4 –1 –5 –5 4 4 –2 , 1 1 , 5 5 , … –3 2 2 6 6 –4 3 3 7 7 • Array of size 1-by-N-by-D. In this case, you can specify different time-varying initial conditions for each channel. For the ramp input [100; 100]' with a frame size of 4, delay of 5, and the parameter settings below, the block outputs the following sequence of frames at the start of the simulation.
Variable Integer Delay Maximum delay The maximum delay that the block can produce for any sample. Delay input values exceeding this maximum are clipped at the maximum. Initial conditions The values with which the block’s memory is initialized.
Variable Selector Purpose 5Variable Selector Library Signal Management / Indexing Description The Variable Selector block extracts a subset of rows or columns from the M-by-N input matrix at the In port, u. Select a subset of rows or columns from the input. When the Select parameter is set to Rows, the Variable Selector block extracts rows from the input matrix, while if the Select parameter is set to Columns, the block extracts columns.
Variable Selector • Clip index – Clip the index to the nearest valid value, and do not issue an alert. Example: For a 64-by-N input, an index of 72 is clipped to 64; an index of -2 is clipped to 1. • Clip and warn – Display a warning message in the MATLAB command window, and clip as above. • Generate error – Display an error dialog box and terminate the simulation. Note The Variable Selector block always copies the selected input rows to a contiguous block of memory (unlike the Simulink Selector block).
Variable Selector Elements A vector containing the indices of the input rows or columns that will appear in the output matrix. This parameter is available when Fixed is selected in the Selector mode parameter. Tunable. Invalid index Response to an invalid index value. Tunable.
Variance Purpose 5Variance Library Statistics Description The Variance block computes the variance of each column in the input, or tracks the variance of a sequence of inputs over a period of time. The Running variance parameter selects between basic operation and running operation. Compute the variance of an input or sequence of inputs.
Variance element yij containing the variance of element uij over all inputs since the last reset. For frame-based inputs, the output is a frame-based M-by-N matrix with each element yij containing the variance of the jth column over all inputs since the last reset, up to and including element uij of the current input. If the Reset port parameter is set to Non-zero sample, the optional Rst port is enabled and the block resets the running variance when the scalar input at the Rst port is nonzero.
Variance • Sample time = 1 • Samples per frame = 1 The block’s operation is shown in the figure below. In ch1 Simulation time First input Output Rst ch1 ch2 61 13 39 t=0 0 –7 2 2 4 5 1 t=1 0 8 6 0 2 –1 5 t=2 1 –3 0 2 4 1 17 t=3 0 First output ch2 0 0 12.50 2.00 6.33 17.33 30.92 12.92 23.50 9.70 21.47 9.07 Reset 0 0 32.00 8.00 24.33 4.33 23.33 7.58 17.70 5.80 14.17 35.47 The statsdem demo illustrates the operation of several blocks from the Statistics library.
Variance Reset port Enables the Rst input port when set to Non-zero sample, and disables the Rst input port when set to None.
Vector Scope Purpose 5Vector Scope Library DSP Sinks Description The Vector Scope block is a comprehensive tool, similar to a digital oscilloscope, for displaying time-domain, frequency-domain, or user-defined signals. The scope window, display-property settings, axis-property settings, and line-property settings are shared with the Spectrum Scope block. Display a vector or matrix of time-domain, frequency-domain, or user-defined data.
Vector Scope assume that it is time-domain or frequency-domain data. The dialog box parameters give you complete freedom to plot the data in the most appropriate manner. The scope updates the display for each new input frame. The number of sequential frames displayed on the scope is specified by the Time display span parameter for time-domain signals, and the Horizontal display span parameter for user-defined signals.
Vector Scope Scaling the Horizontal Axis for User-Defined Signals To correctly scale the horizontal axis for user-defined signals, the block needs to know the spacing of the data in the input. This is specified by the Increment per sample in input frame parameter, Is. This parameter represents the numerical interval between adjacent x-axis points corresponding to the input data. For example, an input signal sampled at 500 Hz has an increment per sample of 0.002 second.
Vector Scope • Each frame of frequency-domain data shares the same length as the frame of time-domain data from which it was generated; for example, when the FFT is computed on the same number of points as are contained in the time-domain input. • The sample period of the time-domain signal in the simulation is equal to the period with which the physical signal was originally sampled.
Vector Scope user-defined data, a Horizontal display span parameter serves the same function. Both of these parameters must be 1 or greater. See “Displaying Data” on page 5-511 for more information. Display Properties The Vector Scope and Spectrum Scope blocks offer a similar collection of display property settings. These can be exposed in the parameter dialog box by selecting the Display properties check box.
Vector Scope to reposition it in the scope window; double click on the line label to edit the text. Note that when the simulation is rerun, the new edits are lost and the labels revert to the defaults. The Channel legend option can also be set in the Axes menu of the scope window. When Compact display is selected, the scope completely fills the containing figure window. Menus and axis titles are not displayed, and the numerical axis labels are shown within the axes.
Vector Scope Minimum Y-limit and Maximum Y-limit set the range of the vertical axis. If Autoscale is selected from the right-click pop-up menu or from the Axes menu option, the Minimum Y-limit and Maximum Y-limit values are automatically recalculated to best fit the range of the data on the scope. Both of these parameters are available for all input domains. Y-axis title is the text to be displayed to the left of the y-axis. This parameter is available for all input domains.
Vector Scope Line Properties Both the Vector Scope and Spectrum scope also offer a similar collection of line property settings. These can be exposed in the parameter dialog box by selecting the Line properties check box. These properties can also be accessed under the Channels menu in the unzoomed scope view (when Compact display is deselected), or by right-clicking on the scope window.
Vector Scope For example, a five-channel signal would ordinarily generate all five plots with a solid line style. To instead plot each line with a different style, enter - | -- | : | -. | ➀ ➁ ➂ ➃ ➄ These settings plot the signal channels with the following styles. Line Style Appearance Solid Dashed Dotted Dash-dot Solid Note that the first (leftmost) list item, '-', corresponds to the first signal channel (leftmost column of the input matrix).
Vector Scope These settings plot the signal channels with the following styles. Marker Style Appearance Asterisk Point Cross Square Diamond Note that the first (leftmost) list item, '*', corresponds to the first signal channel (leftmost column of the input matrix). See the Marker property of the line function in the MATLAB documentaion for more information about the available markers. Type the word stem instead of one of the basic Marker shapes to produce a stem plot for the data in a particular channel.
Vector Scope These settings plot the signal channels in the following colors (8-bit RGB equivalents shown in the center column). Color RGB Equivalent Black (0,0,0) Blue (0,0,255) Red (255,0,0) Green (0,255,0) Dark purple (192,0,192) Appearance Note that the first (leftmost) list item, 'k', corresponds to the first signal channel (leftmost column of the input matrix). See ColorSpec in the online MATLAB documentaion for more information about the color syntax.
Vector Scope • Save Position automatically updates the Scope position parameter in the Axis properties field to reflect the scope window’s current position and size. To make the scope window open at a particular location on the screen when the simulation runs, simply drag the window to the desired location, resize it as needed, and select Save Position. Note that the parameter dialog box must be closed when you select Save Position in order for the Scope position parameter to be updated.
Vector Scope Dialog Box Scope Properties Dialog Box Scope properties Select to expose Scope properties panel. Tunable. Input domain The domain of the input; Time, Frequency, or User-defined. Tunable. Time display span The number of consecutive frames to display (horizontally) on the scope at any one time. (Visible when the Input domain parameter is Time.) Horizontal display span (Not visible in the dialog box shown; appears under Scope properties when the Input domain parameter is User-defined.
Vector Scope Display Properties Dialog Box Display properties Select to expose Display properties panel. Tunable. Show grid Toggles the scope grid on and off. Tunable. Persistence Causes the window to maintain successive displays. That is, the scope does not erase the display after each frame (or collection of frames), but overlays successive input frames in the scope display. Tunable. Frame number Displays the number of the current frame in the input sequence, when selected with Compact display off.
Vector Scope Open scope immediately Opens the scope from the Vector Scope parameters dialog box while the simulation is running. The check box becomes deselected automatically after use. Tunable. Scope position A four-element vector of the form [left bottom width height] specifying the position of the scope window. (0,0) is the lower-left corner of the display. Tunable. Axis properties Dialog Box Axis properties Select to expose the Axis Properties panel. Tunable.
Vector Scope of frequency-domain data is the same as the length of the frame of time-domain data from which is was generated. (Visible when the Input domain parameter is Frequency.) Tunable. Sample time of original time series The sample period of the original time-domain signal, Ts. (Visible when the Input domain parameter is Frequency.) Tunable. Inherit sample increment from input (Not visible in the dialog box shown; appears under Axis properties when the Input domain parameter is User-defined.
Vector Scope Line Properties Dialog Box Line properties Select to expose the Line Properties panel. Tunable. Line visibilities The visibility of the various channels’ scope traces, on or off. Channels are separated by a pipe (|) symbol. Tunable. Line styles The line styles of the various channels’ scope traces. Channels are separated by a pipe (|) symbol. Tunable. Line markers The line markers of the various channels’ scope traces. Channels are separated by a pipe (|) symbol. Tunable.
Vector Scope See Also Matrix Viewer Spectrum Scope DSP Blockset DSP Blockset See “Viewing Signals” on page 3-80 for related information.
Wavelet Analysis Purpose 5Wavelet Analysis Library Filtering / Multirate Filters Description The Wavelet Analysis block uses the wfilters function from the Wavelet Toolbox to construct a dyadic analysis filter bank that decomposes a broadband signal into a collection of successively more bandlimited components. An n-level filter bank structure is shown below, where n is specified by the Number of levels parameter.
Wavelet Analysis Filter Coefficients The filter coefficients for the highpass and lowpass filters are computed by the Wavelet Toolbox function wfilters, based on the wavelet specified in the Wavelet name parameter. The table below lists the available options. Wavelet Name Sample Wavelet Function Syntax Haar wfilters('haar') Daubechies wfilters('db4') Symlets wfilters('sym3') Coiflets wfilters('coif1') Biorthogonal wfilters('bior3.1') Reverse Biorthogonal wfilters('rbio3.
Wavelet Analysis (except the last) are half that of the output from the previous level. In general, for an input with sample period Tsi = Ts, and bandwidth BW, output yk has sample period Tso,k and bandwidth BWk. k ( 2 )T s T so, k = ( 2 n )T s BW k = BW ---------k 2 BW ---------n 2 (1 ≤ k ≤ n) (k = n + 1) (1 ≤ k ≤ n) (k = n + 1) Note that in frame-based mode, the change in the sample period of output yk is reflected by its frame size, Mo,k, rather than by its frame rate.
Wavelet Analysis Tso = 2 Tsi = 1 Tso = 4 Tso = 8 Tso = 8 Frame-Based Operation An Mi-by-N frame-based matrix input is treated as N independent channels, and the block filters each channel independently over time. The input frame size Mi must be a multiple of 2n, and n is the number of filter bank levels. For example, a frame size of 8 would be appropriate for a three-level tree (23=8). The number of columns in each output is the same as the number of columns in the input.
Wavelet Analysis 2n-1 output samples, before propagating the first analyzed input sample (computed from the input received at t=0). See “Excess Algorithmic Delay (Tasking Latency)” on page 3-91 and “The Simulation Parameters Dialog Box” in the Simulink documentation for more information about block rates and Simulink’s tasking modes. Dialog Box The parameters displayed in the dialog box vary for different wavelet types.
Wavelet Analysis References Fliege, N. J. Multirate Digital Signal Processing: Multirate Systems, Filter Banks, Wavelets. West Sussex, England: John Wiley & Sons, 1994. Strang, G. and T. Nguyen. Wavelets and Filter Banks. Wellesley, MA: Wellesley-Cambridge Press, 1996. Vaidyanathan, P. P. Multirate Systems and Filter Banks. Englewood Cliffs, NJ: Prentice Hall, 1993.
Wavelet Synthesis Purpose 5Wavelet Synthesis Library Filtering / Multirate Filters Description The Wavelet Synthesis block uses the wfilters function from the Wavelet Toolbox to reconstruct a signal that was decomposed by the Wavelet Analysis block. The reconstruction or synthesis process is the inverse of the analysis process, and restores the original signal by upsampling, filtering, and summing the bandlimited inputs in stages corresponding to the analysis process.
Wavelet Synthesis For perfect reconstruction, the Wavelet Synthesis and Wavelet Analysis blocks must have the same parameter settings. Filter Coefficients The filter coefficients for the highpass and lowpass filters are computed by the Wavelet Toolbox function wfilters, based on the wavelet specified in the Wavelet name parameter. The table below lists the available options.
Wavelet Synthesis Tree Structure The wavelet tree structure has n+1 inputs, where n is the number of levels. The sample rate and bandwidth of the output are twice the sample rate and bandwidth of the top input. The sample rate and bandwidth of each additional input (except the last) are half that of the input to the previous level.
Wavelet Synthesis The figure below shows the input and output sample periods for the four 64-channel sample-based inputs to a three-level filter bank. The fastest input has a period of 2, so the output period is 1. Tsi = 2 Tsi = 4 Tso = 1 Tsi = 8 Tsi = 8 Frame-Based Operation An Mi-by-N frame-based matrix input is treated as N independent channels, and the block filters each channel independently over time. The number of columns in the output is the same as the number of columns in the input.
Wavelet Synthesis Latency Zero Latency. The Wavelet Synthesis block has no tasking latency for frame-based operation, which is always single-rate. The block therefore uses the first input samples (received at t=0) to synthesize the first output sample. Nonzero Latency.
Wavelet Synthesis Wavelet order The order for the Daubechies, Symlets, and Coiflets wavelets. This parameter is available only when one of these wavelets is selected in the Wavelet name menu. Filter order [synthesis / analysis] The filter orders for the synthesis and analysis stages of the Biorthogonal and Reverse Biorthogonal wavelets. For example, [2 / 6] selects a second-order synthesis stage and a sixth-order analysis stage.
Window Function Purpose 5Window Function Library DSP Sources, Signal Operations Description The Window Function block has three modes of operation, selected by the Operation parameter as described below. Compute a window, and/or apply a window to an input signal. Operation Modes In each mode, the block first creates a window vector, w, by sampling the window specified in the Window type parameter at M discrete points.
Window Function Window Sampling For the generalized-cosine windows (Blackman, Hamming, and Hann), the Sampling parameter determines whether the window samples are computed in a periodic or a symmetric manner.
Window Function Window Type Description Rectangular Computes a rectangular window. w = rectwin(M) Chebyshev Computes a Chebyshev window with stopband ripple R. w = chebwin(M,R) Hamming Computes a Hamming window. w = hamming(M) Hann Computes a Hann window (also known as a Hanning window). w = hann(M) Hanning Obsolete. This window option is included only for compatibility with older models. Use the Hann option instead of Hanning whenever possible.
Window Function Dialog Box Operation The block’s operation: Apply window to input, Generate window, or Generate and apply window. The input/output port configuration is updated to match the parameter setting. Window type The type of window to apply. Tunable. Window length The length of the window to apply. This parameter is available only when Generate window is selected in the Operation menu. Otherwise, the window vector length is computed to match the input frame size, M.
Window Function Window function name (Not shown in dialog above. Visible for User defined windows.) The name of the user-defined window function to be calculated by the block. Additional parameters for user defined window (Not shown in dialog above. Visible for User defined windows.) Enables the Window function parameters when selected. Select when the user-defined window requires parameters other than the window length. Window function parameters (Not shown in dialog above.
Yule-Walker AR Estimator Purpose 5Yule-Walker AR Estimator Library Estimation / Parametric Estimation Description The Yule-Walker AR Estimator block uses the Yule-Walker AR method, also called the autocorrelation method, to fit an autoregressive (AR) model to the windowed input data by minimizing the forward prediction error in the least-squares sense. This formulation leads to the Yule-Walker equations, which are solved by the Levinson-Durbin recursion.
Yule-Walker AR Estimator Dialog Box Output(s) The type of AR model coefficients output by the block. The block can output polynomial coefficients (A), reflection coefficients (K), or both (A and K). Tunable. Inherit estimation order from input dimensions When selected, sets the estimation order p to one less than the length of the input vector. Tunable. Estimation order The order of the AR model, p. This parameter is enabled when Inherit estimation order from input dimensions is not selected.
Yule-Walker AR Estimator See Also Burg AR Estimator Covariance AR Estimator Modified Covariance AR Estimator Yule-Walker Method aryule 5-548 DSP Blockset DSP Blockset DSP Blockset DSP Blockset Signal Processing Toolbox
Yule-Walker Method Purpose 5Yule-Walker Method Library Estimation / Power Spectrum Estimation Description The Yule-Walker Method block estimates the power spectral density (PSD) of the input using the Yule-Walker AR method. This method, also called the autocorrelation method, fits an autoregressive (AR) model to the windowed input data by minimizing the forward prediction error in the least-squares sense.
Yule-Walker Method Dialog Box Inherit estimation order from input dimensions When selected, sets the estimation order to one less than the length of the input vector. Estimation order The order of the AR model. This parameter is enabled when Inherit estimation order from input dimensions is not selected. Inherit FFT length from estimation order When selected, uses the estimation order to determine the number of data points, Nfft, on which to perform the FFT. Sets Nfft equal to (estimation order + 1).
Yule-Walker Method Supported Data Types Double-precision floating point See Also Burg Method Covariance Method Levinson-Durbin Autocorrelation LPC Short-Time FFT Yule-Walker AR Estimator pyulear DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset DSP Blockset Signal Processing Toolbox See “Power Spectrum Estimation” on page 4-15 for related information.
Zero Pad Purpose 5Zero Pad Library Signal Operations Description The Zero Pad block changes the size of the input matrix from Mi-by-Ni to Mo-by-No by zero-padding or truncating along the rows, the columns, or both dimensions. The dimensions of the output, Mo and No, are specified by the Number of output rows and Number of output columns parameters, respectively. You can set Action when truncation occurs so that the block gives a warning or an error when truncation occurs.
Zero Pad • None When None is selected, the input is passed through to the output without padding or truncation. Example In the model below, the 3-by-3 input is zero-padded along the column dimension to 5-by-3. The parameter settings in the Zero Pad block are: • Zero pad along = Columns • Number of output rows = 5 Dialog Box Zero pad along The direction along which to pad or truncate.
Zero Pad column and row dimensions should be changed; None disables padding and truncation and passes the input through to the output unchanged. Number of output rows The desired number of rows in the output, Mo. This parameter is enabled when Columns or Columns and rows is selected in the Zero pad along menu. Number of output columns The desired number of columns in the output, No. This parameter is enabled when Rows or Columns and rows is selected in the Zero pad along menu.
6 DSP Function Reference DSP Blockset Utility Functions . . . . . . . . . . .
6 DSP Function Reference DSP Blockset Utility Functions In addition to the blocks contained in the DSP Blockset libraries, a number of utility functions and scripts are provided in the toolbox\dspblks\dspblks directory.
dsp_links Purpose 6dsp_links Display library link information for blocks linked to the DSP Blockset. Syntax dsp_links dsplinks(sys) dsplinks(sys,mode) Description dsp_links displays library link information for blocks linked to the DSP Blockset. For each block in the current model, dsp_links replaces the block name with the full pathname to the block’s library link in the DSP Blockset.
dsplib Purpose 6dsplib Open the main DSP Blockset library. Syntax dsplib dsplib ver Description dsplib opens the current version of the main DSP Blockset library. dsplib ver opens version ver of the DSP Blockset library, where ver can be 2, 3, or 4. When you launch an older version of the DSP Blockset, MATLAB displays a message reminding you that a newer version exists.
dspstartup Purpose 6dspstartup Configure the Simulink environment for DSP systems. Syntax dspstartup Description dspstartup configures a number of Simulink environment parameters with settings appropriate for a typical DSP project. When the Simulink environment has successfully been configured, the function displays the following message in the command window. Changed default Simulink settings for DSP systems (dspstartup.m).
dspstartup See Also 6-6 Parameter Setting StartTime 0.
liblinks Purpose 6liblinks Display library link information for blocks linked to the DSP Blockset. Syntax liblinks liblinks(sys) liblinks(sys,mode,lib) liblinks(sys,mode,lib,clrs) blks = liblinks(...) Description Please see the command line help for liblinks. Type help liblinks in the MATLAB command window.
rebuffer_delay Purpose 6rebuffer_delay Compute the number of samples of delay introduced by buffering and unbuffering operations. Syntax d = rebuffer_delay(f,n,m) d = rebuffer_delay(f,n,m,'singletasking') Description d = rebuffer_delay(f,n,m) returns the delay (in samples) introduced by the buffering and unbuffering blocks in multitasking operations, where f is the input frame size, n is the Buffer size parameter setting, and m is the Buffer overlap parameter setting.
Index Symbols f (linear frequency). See frequencies fnyq (Nyquist frequency). See frequencies Fs (sample frequency or rate) See sample periods M (frame size). See frame sizes and matrices Mi (input frame size). See frame sizes Mo (output frame size). See frame sizes N (number of channels) See sample vectors and matrices ω (digital frequency). See frequencies Ω (angular frequency).
Index analytic signal 5-27 Analytic Signal block 5-27 angular frequency defined 3-5 See also periods arrays exporting matrix data to 3-73 importing 3-65 attenuation, stopband 4-8 audio exporting 3-79, 5-444, 5-449 importing 5-217, 5-222 autocorrelation and Levinson-Durbin recursion 5-265 of a real vector 5-29 sequence 5-549 Autocorrelation block 5-29 Autocorrelation LPC block 5-31 autocorrelation method 5-546 auto-promoting rates 3-9 autoregressive models using Burg AR Estimator block 5-48 using Burg Metho
Index with Delay Line block 5-124 with preservation of the signal 3-25 with Queue block 5-353 with Stack block 5-413 with Triggered Delay Line block 5-453 Buffers library 5-10 Burg AR Estimator block 5-48 Burg Method block 5-50 butter 4-8 Butterworth filter designs analog 4-8 band configurations for 4-8 using Analog Filter Design block 5-23 C C code, generating 1-5 canonical forms 5-134, 5-433 channels in a frame-matrix 1-10 of a sample-based signal 3-11 cheby1 4-8 cheby2 4-8 Chebyshev type I filter desig
Index for Triggered Signal To Workspace block 5-460 controller canonical forms 5-24 conventions technical 1-10 time and frequency 3-4 conventions in our documentation (table) 1-12 Convert 1-D to 2-D block 5-93 Convert 2-D to 1-D block 5-95 Convert Complex DSP To Simulink block 5-96 Convert Complex Simulink To DSP block 5-98 converting frame rates. See rate conversion sample rates.
Index discrete sample time, defined 3-10 discrete-time blocks nonsource 3-10 source 3-10 discrete-time signals characteristics 3-4 defined 3-3 terminology 3-4, 3-5 See also signals discretizing a continuous-time signal 3-10 Display block 5-10 displaying blocks for 5-10 frame-based data 5-511 matrices as images 5-292 doc 1-8 documentation Signal Processing Toolbox 5-542 Downsample block 3-22, 3-23, 5-141 downsampling 5-141, 5-193, 5-207 See also rate conversion DSP Blockset accessing 1-8 documentation 1-9 f
Index Event-Count Comparator block 5-168 events, triggering for N-Sample Enable block 5-325, 5-327 for Sample and Hold block 5-383 for Stack block 5-354, 5-414 for Triggered Shift Register block 5-453 for Triggered Signal From Workspace block 5-456 for Triggered Signal To Workspace block 5-460 exponentials, complex 5-86, 5-398 exporting blocks for 3-72, 5-10 sample-based signals 3-73 using Triggered Signal To Workspace block 5-460 exporting signals 3-72 Extract Diagonal block 5-170 Extract Triangular Matri
Index continuous-time 4-7 working with 4-3 Filter Designs library 4-4, 5-9 designing digital filters 4-5 designing filters with various filter structures 4-6 Filter Realization Wizard 5-183 filter realizations canonical forms 5-134, 5-433 lattice 5-438 transposed direct-form II IIR 5-134, 5-433 using Filter Realization Wizard 5-183 filtering adaptive.
Index benefits 3-86 frame-based signals benefits of 3-14 changing frame size 3-47 converting to sample-based signals 3-31, 3-60 creating 3-47 creating from sample-based signals 3-47 unbuffering 3-60 frame-matrices format of 3-12 frames changing size of 5-41 unbuffering to scalars 5-463 Framing parameter 3-21 frequencies normalized 4-8 normalized linear 3-5 terminology 3-4 See also periods frequency distributions 5-224 computing 5-224 From Wave Device block 5-217 From Wave File block 5-222 Fs (sample freque
Index continuous-time 4-7 images, displaying matrices as 5-292 importing arrays 3-65 blocks for 5-10 frame-based signals 3-68 pages of an array 3-65 sample-based matrices 3-65 sample-based signals 3-63, 3-65, 3-68 sample-based vectors 3-63 scalars 5-222 signals 3-62, 5-388, 5-456 vectors 5-222 indexing to deconstruct multichannel signals 3-55 Indexing library 5-10 inf parameter setting 2-6 info 1-9 Inherit Complexity block 5-239 inheriting sample periods 3-10 initial conditions, with basic algorithmic dela
Index Math Functions 5-9 Math Operations 5-9 Matrices and Linear Algebra 5-9 Matrix Factorizations 5-9 Matrix Functions 5-9 Matrix Inverses 5-9 Matrix Operations 5-9 Multirate Filters 5-9 opening 1-8 Parametric Estimation 5-9 Polynomial Functions 5-9 Power Spectrum Estimation 5-9 Quantizers 5-9 Signal Attributes 5-10 Signal Management 5-9 Signal Operations 5-10 Simulink 2-3, 2-5 Statistics 4-21, 5-10 Switches and Counters 5-10 Transforms 5-10 Library Browser, using 2-4 line widths displaying 3-22 linear al
Index transposing 5-451 Matrices and Linear Algebra library 5-9 Matrix 1-Norm block 5-280 Matrix Concatenation block 5-14 Matrix Factorizations library 5-9 Matrix Functions library 5-9 Matrix Inverses library 5-9 Matrix Multiply block 5-282 Matrix Operations library 5-9 Matrix Product block 5-284 Matrix Scaling block 5-286 Matrix Square block 5-288 Matrix Sum block 5-290 in tutorial 2-6 Matrix Viewer block 3-83, 5-292 maximum 4-21 Maximum block 5-298 mean 4-21 computing 5-303 Mean block 4-21, 5-303 Median
Index defined 3-4 O ω (digital frequency) defined 3-5 See also frequencies Ω (angular frequency) defined 3-5 See also frequencies Ωp (passband edge frequency) See edge frequencies Ωp1 (lower passband edge frequency) See edge frequencies Ωp2 (upper passband edge frequency) See edge frequencies Ωs (stopband edge frequency) See edge frequencies Ωs1 (lower stopband edge frequency) See edge frequencies Ωs2 (upper stopband edge frequency) See edge frequencies ones, outputting 5-325 online help 1-8 Out block, s
Index phase angles, unwrapping 5-474 phase unwrap 5-474 Polynomial Evaluation block 5-343 Polynomial Functions library 5-9 Polynomial Stability Test block 5-345 polyphase filter structures 5-193, 5-200, 5-207 ports, connecting 2-7 power spectrum estimation using the Burg method 5-50, 5-113, 5-316 using the short-time, fast Fourier transform (ST-FFT) 5-385 using the Yule-Walker AR method 5-549 Power Spectrum Estimation library 5-9 prediction, linear 5-31 predictor algorithm 5-249 Probe block 3-17 example 3-
Index RLS Adaptive Filter block 5-375 RMS block 4-21, 5-379 RMS, computing 5-379 root-mean-square. See RMS Rp (passband ripple) See passband ripple Rs (stopband attenuation) See stopband attenuation RTW.
Index creating from vectors 5-463 exporting 5-460 importing 5-222, 5-388 Scope block 2-7 scopes 3-80 scripts 6-2 seconds 3-4 selecting elements of a vector 5-504 Selector block 5-15 sequences defining a discrete-time signal 3-3 settings, Simulink 2-11 Shift Register block initial state of 5-126 Short-Time FFT block 5-385 short-time, fast Fourier transform (ST-FFT) method 5-385 Signal Attributes library 5-10 Signal dimensions 2-8 Signal From Workspace block 5-388 compared to Simulink To Workspace block 5-38
Index single-rate models 3-92 single-tasking mode 3-6, 3-91 Singular Value Decomposition block 5-405 size of a frame See also frame sizes of a matrix 1-10 of an array 1-11 size of a vector defined 1-11 See also frame sizes sliding windows example 4-22 Solver options panel, recommended settings 3-5 Solver parameter 2-15 solvers fixed-step 3-7 variable-step 3-7 Sort block 5-407 sound exporting 3-79, 5-444, 5-449 importing 5-217, 5-222 source blocks defined 3-9 sample periods of 3-9 sources discrete-time 3-10
Index tasking latency defined 3-91 example 3-93 predicting 3-92 tasking modes 3-91 technical conventions 1-10 terminology, time and frequency 3-4, 3-5 Tf (frame period) defined 3-4 See also frame periods Tfi (input frame period) defined 3-4 See also frame periods Tfo (output frame period) defined 3-4 See also frame periods throughput rates, increasing 3-14 Time check box 2-13 Time Scope Block 5-10 Time Scope block 5-432 time-step vector, saving to workspace 2-13 Time-Varying Direct-Form II Transpose Filter
Index partial 3-25 to a sample-based signal 3-26 Uniform Decoder block 5-466 Uniform Encoder block 5-470, 5-471 units of time and frequency measures 3-4 Unwrap block 5-474 unwrapping radian phase angles 5-474 Upsample block 3-22, 5-484, 5-486 upsampling 3-21, 5-200, 5-207, 5-369 by inserting zeros 5-484 See also rate conversion utility functions 6-2 dsp_links 6-3 dsplib 6-4 dspstartup 6-5 rebuffer_delay 6-8 V Variable Fractional Delay block 5-491 initial conditions for 5-491, 5-492 Variable Integer Delay
Index Z Zero Pad block 3-25, 3-27, 5-552 Zero-Order Hold block 3-10 zero-padding 3-30, 5-337, 5-552 causing unintentional rate conversions 3-31 zeros inserting 5-200, 5-207, 5-484 outputting Counter block 5-105 Discrete Impulse block 5-138 Integer Delay block 5-244 N-Sample Enable block 5-325 Signal From Workspace block 5-388, 5-457 padding with 3-27, 3-31 I-19