DSP Blockset    

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 symbol "[1x2]" appears on the output line from Sine Wave indicating that the output is a 1-by-2 matrix.
  1. At each sample time, the output matrix contains one sample from each of the two sinusoids. The Matrix Sum block adds the two matrix elements together to produce a scalar output. Thus, the input to the Scope block is the point-by-point sum of the two sinusoids.

  1. Double-click on the Scope block if the Scope window is not already open on your screen. The scope window appears.
  2. 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.
  3. Adjust the Scope block's display.
    1. While the simulation is running, right-click on the y-axis of the scope and select Autoscale. The vertical range of the scope is adjusted to better fit the signal.
    2. Click the Properties button on the scope, , and enter 0.1 for Time range. This resizes the scope's time axis to display only one cycle of the signal.
  4. Vary the Sine Wave block parameters.
    1. While the simulation is running, double-click on the Sine Wave block to open it.
    2. Change the frequencies of the two sinusoids. Try entering [1 5] or [100 400] in the Frequency field. Click Apply after entering each new value, and observe the changes on the scope.
  5. Select Stop from the Simulation menu to stop the simulation.

Tunable Parameters

Many parameters cannot be changed while a simulation is running. This is usually the case for parameters that directly or indirectly alter a signal's dimensions or sample rate. There are some parameters, however, such as the Sine Wave Frequency parameter, that you can change or tune while a simulation runs. In the online block reference pages, these parameters are marked "Tunable" in the parameter descriptions.

How to Tune Tunable Parameters.   To tune a tunable parameter during a simulation, double-click the block to open its Block Parameters dialog, change any tunable parameters to the desired settings, and then click OK or Apply. The simulation continues to run, but with the new parameter settings.

Tunability in Simulation, Accelerator, and External Mode.   Block parameters can be tunable in simulation, in the Simulink Performance Tools Accelerator, and in Real-Time Workshop external mode. When a parameter is marked "Tunable" in a reference page, it is tunable only in simulation, unless indicated otherwise.

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 and "Running a Simulation from the Command Line" in the Simulink documentation.


  Model Definition Learning More About Simulink