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('all')
closes all open model windows, discarding all
changes.
Examples
Close Model
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');
Close Multiple Models With Single Function Call
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'})
Clear Model from Memory
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.
Clear Multiple Models from Memory With Single Function Call
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
sys
— Model to close
character vector | string scalar | cell array
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 R2006aR2019b: Closing a window for a model hierarchy closes referenced models
Starting in R2019b, when you close a window for a model hierarchy by closing the
top model, all referenced models that are not open in another window are also
closed, which clears them from memory. To keep referenced models loaded in memory,
use the close_system
function and set the
'closeReferencedModels'
argument to
false
.
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)