Personal tools


Document Actions
  • Content View
  • Bookmarks
  • CourseFeed
  1. For each lab, I recommend that you write a Matlab script in which you define important variables.  A Matlab script is a text file with a ".m" extension.  Executing your script in the Matlab environment will instantiate all the variables defined in the script.  You can use the variables to configure the blocks and the simulation parameters in your Simulink model. Writing a script will save you time if you have to stop working on the lab and come back to it later.  Simply run your script in Matlab, open your Simulink model and you can pick up right where you left off.
  2. In this lab, the kinds of things you can define in your script are variables such as the sample rate, the carrier frequency, the duration of the simulation, and so on.  You can define signals in the script such as the "x" signal in this lab.  You can also design filters in your script such as the low pass filter needed for demodulation in this lab.
  3. Setting the sample rate:  All source blocks need to know how fast they should let samples out into the model. In this lab, there are two source blocks.  Let's look at each one separately.
    • "Signal From Workspace" block:  If the signal "x" and variable "fs" are defined in the Matlab workspace, then you can configure the "Signal From Workspace" block as shown below.  Note how the "Sample time" is derived from the sample rate variable "fs".

    • "Sine Wave" block: If the variables "fc" and "fs" are defined in the Matlab workspace, then you can configure the "Sine Wave" block as shown below.  Note that the carrier frequency is entered with units of Hertz.  Also, to output a cosine wave using a sine block, a "pi/2" radian phase offset is needed.

  4. "Discrete Filter" block:  If you have the filter vector "h" defined in the Matlab workspace, then you can configure the "Discrete Filter" block as shown below.  This block implements a rational transfer function.  The numerator and denominator polynomials are specified by listing their coefficients in vectors.  In this case, we are using an FIR filter which has only a numerator polynomial.  That is why we put "1" in the denominator.  Note that, like the source blocks, this block needs to know the "Sample time".  You could enter "1/fs" as we did in the source blocks, or, this block has a default option of "-1" which tells this block to look back to other blocks that preceed it to find out what the sample rate is.

  5. "Configuration Parameters" dialog accessible from the "Simulation" drop down menu:  If you have defined the variables "NumSamples" and "fs" in the Matlab workspace, then you can configure the "Configuration Parameters" dialog as shown below.  In my Matlab script, I define the variable "NumSamples" to be the length of the input signal "x".  Setting the "Start time" and "Stop time" as shown below will make sure that all of the input signal is input into the simulation.  Make sure that you set the "Solver options" as shown below.

Copyright 2008, by the Contributing Authors. Cite/attribute Resource . admin. (2006, June 28). Hints. Retrieved January 07, 2011, from Free Online Course Materials — USU OpenCourseWare Web site: This work is licensed under a Creative Commons License Creative Commons License