Main Content

Generate MATLAB Code for Sensitivity Analysis Statistics to Identify Key Parameters (GUI)

This example shows how to automatically generate a MATLAB function to solve a Sensitivity Analysis statistics problem. You use theSensitivity Analyzerto define a sensitivity statistics problem for a model of the body's vestibulo-ocular reflex, and generate MATLAB® code to solve this statistics problem.

Vestibulo-Ocular Reflex Sensitivity Statistics Problem

TheIdentify Key Parameters for Estimation (GUI)example shows how to use theSensitivity Analyzerto compute sensitivity statistics for different parameter values in a model of the body's vestibulo-ocular reflex. In this example, we load a preconfiguredSensitivity Analyzersession based on that example.

Open theSensitivity Analyzerfor the sdoVOR model:

ssatool('sdoVOR')

In theSensitivity Analyzer, clickOpen SessionandOpen from model workspace. Open sessionsdoVOR_sasessionForSensitivityStatistics.

这将打开一个预配置会话中Sensitivity Analyzer.

Generate MATLAB Code

From theCompute Statisticslist, selectGenerate MATLAB Function.

The generated code is added to the MATLAB editor as an unsaved MATLAB function.

Examine the generated code. Significant portions are:

  • Statistics Analysis Variables- Specify the inputs and outputs, to determine which inputs have the most influence on outputs.

  • Statistics Options- Specify the types of analyses to be computed.

  • Compute Statistics- Solve the sensitivity statistics problem using the sdo.analyze command.

SelectSavefrom the MATLAB editor to save the generated function.

Run Generated Code

Run the generated function.

The computation shows the result of analyzing which inputs have the most influence on the output. For example, theCorrelationfield shows that theGainparameter has the largest magnitude correlation with the output, and in a negative direction, meaning that when Gain increases, the output decreases.

Modify the Generated Code

You can:

  • Modify the specified input and output variables.

  • Modify the options to change the types of analyses computed.

Related Topics