Close Simulink system window or block dialog box


close_system('sys', saveflag)
close_system('sys', 'newname')
close_system('sys', 'newname','ErrorIfShadowed', true)


close_system with no arguments closes the current system or subsystem window. If the current system is the top-level system and it has been modified, close_system returns an error. The current system is defined in the description of the gcs command.

close_system('sys') closes the specified system, subsystem, or block window.

close_system('sys') unloads a model after specifying

  • load_system('sys').

'sys' can be a character vector (which can be a system, a subsystem, or a full block pathname), a cell array of character vectors, a numeric handle, or an array of numeric handles. This command displays an error if 'sys' is a MATLAB® keyword, 'simulink', or more than 63 characters long.

close_system('sys', saveflag), if saveflag is 1, saves the specified top-level system to a file with its current name, then closes the specified top-level system window and removes it from memory. If saveflag is 0, the system is closed without saving. A single saveflag can be supplied, in which case it is applied to all block diagrams. Alternatively, separate saveflags can be supplied for each block diagram, as a numeric array.

close_system('sys', 'newname') saves the specified top-level system to a file with the specified new name, then closes the system.

Additional arguments can be supplied when saving a block diagram. These are exactly the same as for save_system:

  • ErrorIfShadowed: true or false (default: false)

  • BreakAllLinks: true or false (default: false)

  • SaveAsVersion: MATLAB version name (default: current)

  • OverwriteIfChangedOnDisk: true or false (default: false)

  • SaveModelWorkspace: true or false (default: false)

If you try to specify additional options when you are doing something other than saving a block diagram, they are ignored. You see a warning if you try to save when closing something other than a block diagram (e.g., a subsystem or a Block Properties dialog).


This command closes the current system.


This command closes the vdp system, unless it has been modified, in which case it returns an error.


This command saves the engine system with its current name, then closes it.

close_system('engine', 1)

This command saves the mymdl12 system under the new name testsys, then closes it.

close_system('mymdl12', 'testsys')

This command tries to save the vdp system to a file with the name 'max', but returns an error because 'max' is the name of an existing MATLAB function.

close_system('vdp','max','ErrorIfShadowed', true)

All three of the following commands save and close mymodel (saved with the same name), and replace links to library blocks with copies of the library blocks in the saved file:


This command closes the dialog box of the Unit Delay block in the Combustion subsystem of the engine system.

close_system('engine/Combustion/Unit Delay')


The close_system command cannot be used in a block or menu callback to close the root-level model. Attempting to close the root-level model in a block or menu callback results in an error and discontinues the callback's execution.

Introduced before R2006a

Was this topic helpful?