xPC Target |
 |
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.
- In the MATLAB Command Window, type
- Simulink runs a simulation in normal mode.
- You can either let the simulation run to its stop time, or stop the simulation manually. To stop the simulation manually, press Ctrl+T.
- After Simulink finishes the simulation, type
- You entered the MATLAB variables
tout
and yout
in the
Workspace I/O pane on the Simulation Parameters dialog box. The signals are logged into memory through Outport blocks. To add an Outport block, see Adding a Simulink Outport Block and Entering Parameters for 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 running your target application in real time, data is not saved to the variables tout and yout . Instead, data is saved in the target PC memory and may be retrieved through the target object properties tg.TimeLog , tg.StateLog , and tg.OutLog . However, in the Simulation Parameters dialog box, you must still select the Time, States, and Output check boxes for data to be logged into the target object properties.
|
Your next task is to create a target application. See xPC Target Application.
| Simulating the Model with Simulink | | xPC Target Application |  |