Contenu principal

bdclose

R2026b

Close any or all Simulink model windows unconditionally without saving changes

Description

bdclose closes the current model window unconditionally and without confirmation. Any changes made to the model since it was last saved are lost. To find out the current model, use gcs. If a model was only loaded, the bdclose function clears the model from memory.

Tip

When you close a model with the bdclose function, the model is no longer loaded. To close a model but keep the model loaded, use this command instead, where model is the handle or name of the model.

set_param(model,Open="off")
To unload the model after running this command, you can use the bdclose or close_system function.

example

bdclose(sys) closes the specified model window, discarding all changes.

example

bdclose("all") closes all open model windows, discarding all changes.

Examples

collapse all

Suppose the current model is a loaded model with unsaved changes. Clear the model from memory without saving any of the changes.

Check that the model is loaded.

bdIsLoaded(gcs)
ans =
  logical
   1

The output is 1, indicating that the model is loaded.

Clear the model from memory without saving the changes.

bdclose;

Check if the model is loaded.

bdIsLoaded(gcs)
ans =
  logical
   0

The output is 0, indicating that the model is cleared from memory.

Suppose you have three models open, myModel1, myModel2, and myModel3. The models have unsaved changes.

Close myModel1 and myModel3.

mdls = ["myModel1","myModel3"];
bdclose(mdls);

Input Arguments

collapse all

Model to close, specified as a one or more handles or model names. Format handles as numeric scalars or numeric arrays. Format model names as a string, string array, character vector, or cell array of character vectors.

For information about getting handles, see Get Handles and Paths.

Example: bdclose("myModel")

Example: bdclose(["myModel1","myModel2"])

Data Types: double | array of doubles | string | string array | character vector | cell array of character vectors

Version History

Introduced before R2006a

expand all