Main Content


Update experiment input and output data

Since R2020a



Experiment_out = updateIOData(Experiment,sigName,data) updates the signal sigName of the experiment object Experiment with data specified in data.

updateIOData lets you reuse the experiment definition but with different data. The function is particularly useful for deployed applications where you do not want to redefine the experiment each time you execute the deployed application.

Experiment_out = updateIOData(Experiment,sigName1,data1,sigName2,data2,...) updates multiple signals of an experiment object for deployment with Simulink® Compiler™.

Input Arguments

expand all

Experiment definition for Simulink model, specified as an sdo.Experiment object.

Signal to be updated, specified as a string. You can specify sigName using the full signal block path or by the signal name if the signal names in the Simulink model are unique.

You can specify multiple sigName and data pairs to update multiple inputs or outputs in one call to updateIOData.

Data for the signal update, specified as a time series or vector.

You can specify multiple sigName and data pairs to update multiple inputs or outputs in one call to updateIOData.

Output Arguments

expand all

Experiment with updated input and output data, returned as an sdo.Experiment object.


expand all

For this example, set up your parameter estimation problem using the Parameter Estimator app and generate MATLAB code from it. For more information on generating MATLAB code from the app, see Generate MATLAB Code for Parameter Estimation Problems (GUI). Alternatively, you can also set up your estimation problem at the command line.

Next, split the generated MATLAB code just before the estimation objective function is defined. This results in two files - a run function and a setup function, as described in Parameter Tuning for Digital Twins.

In the setup function, add the following lines of code at the end to configure the experiment and simulation test objects for deployment and save them to a MAT-file.

Experiment_out = prepareToDeploy(Experiement);
Simulator = createSimulator(Experiment_out);
Simulator = prepareToDeploy(Simulator,p);
save ObjectsToDeploy Experiment_out Simulator p

In the run function, add the following lines of code at the beginning of the function to include the Simulink model in the compiled code and load the objects that were saved in the setup function.

%#function simulink_model_name.slx
load ObjectsToDeploy Experiment_out Simulator p

Next, add the following lines to load the experiment data and update the experiment object. For this example, assume that the experiment data is contained in the first three columns of a Microsoft Excel spreadsheet file named fname.xls.

d = xlsread(fname);
u = timeseries(d(:,3),d(:,1));
y = timeseries(d(:,2),d(:,1));
Experiment_out = updateIOData(Experiment_out,'simulink_model_name/param1',u);
Experiment_out = updateIOData(Experiment_out,'simulink_model_name/param2',y);

For a detailed example showing how to deploy your parameter estimation problem using the Simulink Compiler, see Parameter Tuning for Digital Twins.

Version History

Introduced in R2020a