| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → xPC Target |
| Contents | Index |
| Learn more about xPC Target |
| On this page… |
|---|
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.
xpc_osc2
MATLAB loads the oscillator model and displays the Simulink block diagram, as shown below.

In the Simulink window, double-click the Scope block.
Simulink opens a scope window.
From the Simulation menu, click Normal, and then click Start.
The Scope1 window displays a trace of the signal data.

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.
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.
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.
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.

Note When your target application is running in real time, data is not saved to the variables tout and yout. Instead, data is saved in the target PC memory and can be retrieved through the target object properties tg.TimeLog, tg.StateLog, and tg.OutLog. However, in the Configuration Parameters dialog box, you must still select the Time, States, and Output check boxes for data to be logged to the target object properties. |
Your next task is to create a target application. See xPC Target Application.
![]() | Simulink Model | xPC Target Application | ![]() |

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 |