Main Content

bdclose

Close any or all Simulink model windows unconditionally

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, bdclose clears the model from memory.

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

example

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

Examples

collapse all

Open the example. Then, open the vdp model.

open_system('vdp')

The bdclose function closes models even when they have unsaved changes. Make a change to the model.

set_param('vdp/Constant','Value','4')

Close the vdp model.

bdclose('vdp');

Open the example. Then, load the vdp and f14 models.

h1=load_system('vdp');
h2=load_system('f14');

Open the vdp and f14 models.

open_system([h1, h2])

The bdclose function closes models even when they have unsaved changes. Make a change to the vdp model.

set_param('vdp/Constant','Value','4')

Close the vdp and f14 models. Specify the model to close as a matrix of handles.

bdclose([h1,h2])

In the bdclose function arguments, you can also specify the models to close as a cell array of character vectors.

Open the vdp and f14 models again.

open_system({'vdp','f14'})

Close the vdp and f14 models. Specify the model to close as a cell array of character vectors.

bdclose({'vdp','f14'})

Open the example. Then, load the vdp model.

load_system('vdp')

Check whether the vdp model is loaded.

bdIsLoaded('vdp')
ans = logical
   1

The function returns a logical scalar, 1, which indicates that the model is loaded.

The bdclose function clears models from memory even when they have unsaved changes. Make a change to the model.

set_param('vdp/Constant','Value','4')

Check whether the model is dirty.

bdIsDirty('vdp')
ans = logical
   1

The function returns a logical scalar, 1, which indicates that the model is dirty.

Open the example. Then, load the vdp and f14 models.

h1=load_system('vdp')
h1 = 
152.0013
h2=load_system('f14')
h2 = 
357.0039

Clear the vdp and f14 models from memory. Specify the models to clear as a matrix of handles.

bdclose([h1,h2])

Check whether the vdp and f14 models are loaded.

bdIsLoaded({'vdp','f14'})
ans = 1x2 logical array

   0   0

The function returns the logical array [0 0], which indicates that both models are not loaded. The models are cleared from memory.

In the bdclose function arguments, you can also specify the models to clear using a cell array of character vectors.

Load the vdp and f14 models again.

load_system('vdp')
load_system('f14')

Clear the vdp and f14 models from memory. Specify the models to clear as a cell array of character vectors.

bdclose({'vdp','f14'})

Check whether the vdp and f14 models are loaded.

bdIsLoaded({'vdp','f14'})
ans = 1x2 logical array

   0   0

The function returns [0 0], which indicates that both models are not loaded.

Input Arguments

collapse all

Model to close, specified as a character vector, string scalar, or cell array. To specify multiple models to close, specify a cell array of model names.

Example: bdclose("myModel")

Example: bdclose({'myModel1','myModel2'})

Data Types: char | string | cell

Version History

Introduced before R2006a

expand all