Main Content

Simulink.fault.exportEmbeddedModel

R2026b

Export model that has embedded faults

Since R2025a

Description

newModelHandle = Simulink.fault.exportEmbeddedModel(model,newModel,saveFolder) exports a version of the model, model, that contains embedded faults, and saves the model with the name newModel, in the folder saveFolder.

When you create a fault-embedded model by using this function, the function copies Simscape™ blocks and their faults as-is.

For more information on exporting models that have embedded faults, see Create Fault-Embedded Models.

example

newModelHandle = Simulink.fault.exportEmbeddedModel(model,newModel,saveFolder,Name=Value) exports a version of the model by using one or more name-value arguments.

example

Examples

collapse all

Open the fault_analyzer_intro model.

openExample("faultanalyzer/FaultAnalyzerIntroExample")

Add a fault to the output port of the Sine Wave block.

myModel = "fault_analyzer_intro";
myFault = Simulink.fault.addFault(myModel + "/Sine Wave/Outport/1");

Assign the noise behavior from the mwfaultlib library to the fault and store the behavior in a fault model named myBehaviorModel on the path.

addBehavior(myFault,"myBehaviorModel",...
FaultBehavior="mwfaultlib/Add Noise");

Export a copy of the model that has embedded faults with the name myExportedModel and save it in the myFolder folder on the C: drive.

Simulink.fault.exportEmbeddedModel(myModel,...
"myExportedModel","C:\myFolder");

Open the fault_analyzer_intro model.

openExample("faultanalyzer/FaultAnalyzerIntroExample")

Add a fault to the output port of the Sine Wave block.

myModel = "fault_analyzer_intro";
myFault = Simulink.fault.addFault(myModel + "/Sine Wave/Outport/1");

Assign the noise behavior from the mwfaultlib library to the fault and store the behavior in a fault model named myBehaviorModel on the path.

addBehavior(myFault,"myBehaviorModel",...
FaultBehavior="mwfaultlib/Add Noise");

Suppose that you have a model named anotherModel in the myFolder folder on the C: drive. Overwrite the existing anotherModel model.

Simulink.fault.exportEmbeddedModel(myModel,...
"anotherModel","C:\myFolder",Overwrite=1);

Input Arguments

collapse all

Path or handle to the model, specified as a string scalar, character vector, or model handle.

Data Types: string | char | double

Name of the model to create with embedded faults, specified as a string scalar or character vector.

Data Types: string | char

Folder to save the new model in, specified as a string scalar or character vector. The folder must exist.

Data Types: char | string

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: Simulink.fault.exportEmbeddedModel(myModel,"anotherModel","C:\myFolder",Overwrite=1);

Whether to delete the existing files in the specified folder before saving the new model, specified as a numeric or logical 0 (false) or 1 (true). If this argument is false and the folder contains at least one file, the function returns an error. You cannot overwrite the model specified by model.

Data Types: logical

Since R2026b

Whether to export all of the faults and their behaviors, specified as a numeric or logical 1 (true) or 0 (false). If the argument is true, the function exports all of the faults and stores their behaviors in variant subsystems on each model element. If this argument is false the function exports only the active faults and stores their behaviors in a subsystem on each model element.

Data Types: logical

Since R2026b

Whether to export the conditionals, specified as a numeric or logical 1 (true) or 0 (false). If the argument is true, the function exports the conditionals and models their logic by using blocks. If this argument is false, the function exports faults that use conditionals as manually triggered faults. Each conditional outputs its status to the subsystem by using a Data Store Memory block.

Data Types: logical

Output Arguments

collapse all

Handle to the exported model, returned as a model handle.

Limitations

  • This function is unable to export faults that have behavior that contains Fault Data Inport blocks.

  • If your original model contains links that you create by using Requirements Toolbox™, the generated model does not contain these links.

Version History

Introduced in R2025a

expand all