Products & Services Solutions Academia Support User Community Company

Learn more about Signal Processing Blockset   

Creating Frame-Based Signals

Using the Sine Wave Block

A frame-based signal is propagated through a model in batches of samples called frames. Frame-based processing can significantly improve the performance of your model by decreasing the amount of time it takes your simulation to run. The Signal Processing Sources library provides the following blocks for automatically generating common frame-based signals:

For information about the specific functionality of these blocks, see their respective block reference pages.

One of the most commonly used blocks in the Signal Processing Sources library is the Sine Wave block. This topic describes how to create a three-channel frame-based signal using the Sine Wave block:

  1. Create a new Simulink model.

  2. From the Signal Processing Sources library, click-and-drag a Sine Wave block into the model.

  3. From the Matrix Operations library, click-and-drag a Matrix Sum block into the model.

  4. From the Signal Processing Sinks library, click-and-drag a Signal to Workspace block into the model.

  5. Connect the blocks in the order in which you added them to your model.

  6. Double-click the Sine Wave block, and set the block parameters as follows:

    • Amplitude = [1 3 2]

    • Frequency = [100 250 500]

    • Sample time = 1/5000

    • Samples per frame = 64

    Based on these parameters, the Sine Wave block outputs three sinusoids with amplitudes 1, 3, and 2 and frequencies 100, 250, and 500 hertz, respectively. The sample period, 1/5000, is 10 times the highest sinusoid frequency, which satisfies the Nyquist criterion. The frame size is 64 for all sinusoids, and, therefore, the output has 64 rows.

  7. Save these parameters and close the dialog box by clicking OK.

    You have now successfully created a three-channel frame-based signal using the Sine Wave block. The rest of this procedure describes how to add these three sinusoids together.

  8. Double-click the Matrix Sum block. Set the Sum over parameter to Specified dimension, and set the Dimension parameter to 2. Click OK.

  9. From the Format menu, point to Port/Signal Displays, and select Signal Dimensions.

  10. Run the model.

    Your model should now look similar to the following figure. You can also open the model by typing doc_usingsinwaveblkfb at the MATLAB command line.

    The three signals are summed point-by-point by a Matrix Sum block. Then, they are exported to the MATLAB workspace.

  11. At the MATLAB command line, type plot(yout(1:100)).

    Your plot should look similar to the following figure.

This figure represents a portion of the sum of the three sinusoids. You have now added the channels of a three-channel frame-based signal together and displayed the results in a figure window.

Using the Signal from Workspace Block

A frame-based signal is propagated through a model in batches of samples called frames. Frame-based processing can significantly improve the performance of your model by decreasing the amount of time it takes your simulation to run. This topic describes how to create a two-channel frame-based signal with a sample period of 1 second, a frame period of 4 seconds, and a frame size of 4 samples using the Signal From Workspace block:

  1. Create a new Simulink model.

  2. From the Signal Processing Sources library, click-and-drag a Signal From Workspace block into the model.

  3. From the Signal Processing Sinks library, click-and-drag a Signal To Workspace block into the model.

  4. Connect the two blocks.

  5. Double-click the Signal From Workspace block, and set the block parameters as follows:

    • Signal = [1:10; 1 1 0 0 1 1 0 0 1 1]'

    • Sample time = 1

    • Samples per frame = 4

    • Form output after final data value by = Setting to zero

    Based on these parameters, the Signal From Workspace block outputs a two-channel, frame-based signal has a sample period of 1 second, a frame period of 4 seconds, and a frame size of four samples. After the block outputs the signal, all subsequent outputs have a value of zero. The two channels contain the following values:

    • Channel 1: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0,...

    • Channel 2: 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0,...

  6. Save these parameters and close the dialog box by clicking OK.

  7. From the Format menu, point to Port/Signal Displays, and select Signal Dimensions.

  8. Run the model.

    The following figure is a graphical representation of the model's behavior during simulation. You can also open the model by typing doc_usingsfwblkfb at the MATLAB command line.

  9. At the MATLAB command line, type yout.

    The following is the output displayed at the MATLAB command line.

    yout =
    
         1     1
         2     1
         3     0
         4     0
         5     1
         6     1
         7     0
         8     0
         9     1
        10     1
         0     0
         0     0
    

Note that zeros were appended to the end of each channel. You have now successfully created a two-channel frame-based signal and exported it to the MATLAB workspace.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS