xPC Target | ![]() ![]() |
Parameter Tuning with MATLAB Commands
You use the MATLAB functions to change block parameters. With these functions you do not need to set Simulink in external mode, and you do not need to connect Simulink with the target application.
You can download parameters to the target application while it is running or between runs. This feature lets you change parameters in your application without rebuilding the Simulink model.
After you download a target application to the target PC, you can change block parameters using MATLAB functions. This procedure uses the Simulink model xpcosc.mdl
as an example, and assumes you have created and downloaded the target application for that model.
tg
The MATLAB window displays a list of the target objects properties.
ShowParameters = On Parameters= PROP VALUE PARAMETER NAME BLOCK NAME P0 0.000000 InitialCondition Integrator1 P1 4.000000 Amplitude Signal Generator P2 20.000000 Frequency Signal Generator P3 1000000.0 Gain Gain P4 0.000000 InitialCondition Integrator P5 400.00000 GainGain1 P6 1000000.0 GainGain2
The parameter names (P0, P1, . . .P6) are properties of the target object. and the signal names (S0,S1, . . .) are also properties of the target object.
As soon as you change parameters, the changed parameters in the target object are downloaded to the target application. The target PC displays the following message.
Param: param 5 updated
And the plot frame updates the signals after running the simulation with the new parameters.
The target application on the target PC stops running, and the target PC displays the following messages.
System: execution stopped minimal TET: 0.000023 at time 1313.789000 maximal TET: 0.000034 at time 407.956000
![]() | Parameter Tuning | Parameter Tuning with Simulink External Mode | ![]() |