Products & Services Solutions Academia Support User Community Company

Learn more about Model-Based Calibration   

Exporting Models

How to Export Models

You can export all models created in the Model Browser using the menu item File > Export Models.

The Export Model dialog box appears.

Choose the export format from the Export to drop-down menu:

If a file format is chosen (export to file or to Simulink), the Destination file controls are enabled, and the browse button allows you to locate a destination file using a file browser.

Export As — Defines the name that the model has when loaded, or the name of the workspace variable.

Export global models — When a two-stage model is being exported (from the response node) the constituent response feature models can also be exported. Multiple models are exported to the workspace as a cell array.

Export all local models — When exporting at the local node, the single local model for the current test is exported. Selecting this control exports the local models for all tests (to the workspace as a cell array).

Export datum models— When exporting a two-stage model that has a datum defined, this control allows you to export the datum global model (without exporting all other response feature models).

Export PEV blocks — When exporting to Simulink, you can create a PEV block as part of the Simulink diagram so that the prediction error variance can be evaluated along with the model. This is not available for models where PEV cannot be calculated.

Export constraints — Where design constraints and boundary constraints exist, you can choose to export them.

Export Preview — Displays the models that are exported with the current choice of options.

For example:

See What Is Exported? for details on what to expect here.

Export information — Traceability information is exported with the models. You can add/edit/delete further comments using the buttons on the right.

Click OK to export the current selection of models and close the dialog box.

What Is Exported?

In the Export Model dialog box you can use the Export Preview button to check the models that have been selected for export. This displays the Models Export List dialog box.

At the test plan node:

At the response node:

At the local node:

At response feature nodes and all child nodes from here:

Evaluating Models in the Workspace

If a model is exported to the workspace as MyModel and has four input factors, it can be evaluated at a point as in this example:

Y = MyModel([3.7, 89.55, -0.005, 1]);

If column vectors p1,p2,p3,p4 (of equal length) are created for each input factor, the model can be evaluated to give a column vector output

Y = MyModel([p1,p2,p3,p4]);

Left to right argument order corresponds exactly to top-down input order in the Test Plan view in the Model Browser.

If you export a group of models, the group is exported as a cell array of models. The argument order in the curly braces {1 to n} cell array reference corresponds exactly to top-down model order in the model tree in the Model Browser.

The inputs and outputs for MATLAB model evaluation are in natural engineering units, not coded units.

It is also possible to evaluate the PEV (prediction error variance) for the model using the command

[pev, y] = pev(MyModel, [x1 x2 x3])

You can use one or two arguments, as follows:

[p]=pev(x) gives pev at x

[p,y]=pev(x) gives pev at x and model eval at x

Evaluating Boundary Models

You can use the function ceval to evaluate a boundary constraint exported to the Workspace. For example, if your exported model is M, then ceval(M, X) evaluates the boundary constraint attached to M at the points given by the matrix X (values less than zero are inside the boundary). See Boundary Model Setup.

For example, if you have exported multiple responses from a test plan as a cell array named modeltutorial, entering the following at the command line evaluates the boundary model for the first response {1} at the point where all 4 inputs are zero.

ceval(modeltutorial{1}, [0,0,0,0])

Response models are in top-down order in the model tree, e.g. in this example {1} is the top model in the tree under the test plan node. [0,0,0,0] is the matrix of input values, where left to right argument order corresponds exactly to top-down input order in the Boundary Editor or the Test Plan view in the Model Browser, e.g. spk, load, rpm, and afr.

You can quickly check the number of model inputs as follows:

nfactors( modeltutorial{1} )

You can click a point in the boundary editor (in the 1-D, 2-D and 3-D views) to check the input names and get example input values to evaluate in the workspace, e.g.

ceval (modeltutorial{1}, [25, 0.64, 5000, 14.43] )

ans = 3.0284e-004

Boundary constraint distance of zero means the point is on the boundary, negative values are inside the constraint, and positive values are outside. The range is typically [-1,1] but not always, and roughly linear. Rather like information criteria it is only a comparison that is meaningful (point x has a greater distance than point y) rather than the absolute value.

Confidence Intervals

The confidence interval is given by:

upperbound = y + t*sqrt(pev)

lowerbound = y - t*sqrt(pev)

Where y is the model prediction, and t is the appropriate percentile of the t-statistic, with df = nObs-1 degrees of freedom. This is calculated using the Statistics Toolbox function tinv as follows:

t = tinv(p,v)

p=confidence level e.g. 95%

v= degrees of freedom (n-1)

t = tinv(1-alpha/2, df)

where alpha = 0.05 for 95% confidence intervals.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS