Main Content

Simulink.fault.exportEmbeddedModel

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. The function exports only the active faults in the model.

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,Overwrite=value) exports a version of the model that has embedded faults and deletes the existing content in the folder based on the value, value.

example

Examples

collapse all

Open the fault_analyzer_intro model.

openExample("faultanalyzer/FaultAnalyzerIntroExample")

Add a fault to the Sine Wave block output port.

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 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 Sine Wave block output port.

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 directory must exist.

Data Types: char | string

Whether the function deletes the existing files in the specified directory 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

Output Arguments

collapse all

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

Limitations

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

  • This function converts active faults that use a conditional trigger into manually triggered faults.

  • 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