Products & Services Solutions Academia Support User Community Company

Learn more about xPC Target   

Simulating the Model

Simulating the Model with Simulink

You use Simulink in normal mode to observe the behavior of your model in nonreal time. After you load your Simulink model, you can run a simulation. This procedure uses the Simulink model xpc_osc2.mdl as an example and assumes you have already loaded that model. To create this model, see Creating a Simple Simulink Model.

For procedures to run your target application in real time, see Running the Target Application.

  1. In the MATLAB window, type

    xpc_osc2

    MATLAB loads the oscillator model and displays the Simulink block diagram, as shown below.

  2. In the Simulink window, double-click the Scope block.

    Simulink opens a scope window.

  3. From the Simulation menu, click Normal, and then click Start.

    The Scope1 window displays a trace of the signal data.

  4. You can either let the simulation run to its stop time, or stop the simulation manually. To stop the simulation manually, from the Simulation menu, click Stop.

Your next task is to create an xPC Target application. See xPC Target Application.

Simulating the Model from MATLAB

You run a simulation of your Simulink model to observe the behavior of the model in nonreal time.

After you load your Simulink model into the MATLAB workspace, you can run a simulation. This procedure uses the Simulink model xpc_osc2.mdl as an example and assumes you have already loaded that model. To create this model, see Creating a Simple Simulink Model.

  1. In the MATLAB window, type

    sim('xpc_osc2')

    Simulink runs a simulation in normal mode through to completion. You cannot manually stop the simulation. See the online Simulink documentation for further information on using the sim command.

  2. After Simulink finishes the simulation, type

    plot(tout,yout)

    You entered the MATLAB variables tout and yout in the Data I/O pane on the Configuration Parameters dialog box. The signals are logged to memory through Outport blocks. To add an Outport block, see Adding a Simulink Outport Block and Entering Parameters for the Outport Blocks.

    MATLAB opens a plot window and displays the output response. The signal from the signal generator is added to the Outport block and shown in the figure below.

Your next task is to create a target application. See xPC Target Application.

  


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