ECET 357 Real-Time Digital Signal Processing

 

Sampling, A/D, and D/A

 

January 18, 2007

 

Lecture Note 2

 

MATLAB Simulink Example

 

 

Step 1. Start MATLAB

 

Step 2. Start Simulink

To start Simulink, you type simulink at the command window

>> simulink

 

 

Step 3. Creating a Simulink Model File:

Click on File → New → Model

 

 

Step 4. Select any needed function blocks, one at a time, on the Simulink Library Browser, and Drag them into the Simulink Model editor screen

For example,

 

Step 5. Setup signal parameters for Sine Wave

 

Step 6. Setup Simulation Parameter

 

Step 7. Start Simulation and View the Scope output

 

 

Step 8. Refine Parameters and More Testing

 

8.1 Change Fixed-step size: 0.01

 

8.2

 

 

·       Double click To Workspace block, and specify a variable name  “sine60”

·       Start simulation to see the Scope output

·       Then go to MATLAB Command window, and type “whos” command to see variables

>> whos

  Name         Size              Bytes  Class

  ans        901x1              271880  cell array

  sine60      11x1                  88  double array

  tout        11x1                  88  double array

·       Then type plot(sine60), and stem(60) to see the MATLAB plots

>> plot(sine60)

>> stem(sine60)

 

8.3 Calculate the sampling time: Nyquist Sampling Rate

 

>> whos

  Name         Size              Bytes  Class

  ans        901x1              271880  cell array

  sine60       2x1                  16  double array

  tout         2x1                  16  double array

·       Then type plot(sine60), and stem(60) to see the MATLAB plots

>> plot(tout,sine60), grid on

>> stem(tout,sine60), grid on

 

 

8.4 Change the Fix-step size to 0.001

>> whos

  Name         Size              Bytes  Class

  ans        901x1                   8  double array

  sine60     101x1                 808  double array

  tout       101x1                 808  double array

·       Then type plot(sine60), and stem(60) to see the MATLAB plots

>> plot(tout,sine60), grid on

>> stem(tout,sine60), grid on

 

 

 

 

 

 

 

 

 

Step 9. Copy Model and Prepare Report