save_system - Save Simulink® system

Syntax

save_system
save_system('sys')
save_system('sys', 'newname')
save_system('sys', 'newname', 'BreakAllLinks', true)
save_system('sys', 'newname', 'BreakUserLinks', true)
save_system('sys', 'newname', 'SaveModelWorkspace', true)
save_system('sys', 'newname', 'ErrorIfShadowed', true)
save_system('sys', 'newname', 'SaveAsVersion', 'version')
save_system('sys', 'newname', 'OverWriteIfChangedOnDisk', true)
save_system('sys', 'newname', 'SaveModelWorkspace', true,
 'BreakLinks', true, 'OverwriteIfChangedOnDisk', true)

Description

save_system saves the current top-level system to a file with its current name.

save_system('sys') saves the specified top-level system to a file with its current name. The system must be open. 'sys' can be a string, a cell array of strings, a numeric handle, or an array of numeric handles.

save_system('sys', 'newname') saves the specified top-level system to a file with the specified new name. The system to be saved must be open. The new name can be a file name, in which case Simulink software saves the system in the working directory, or a fully qualified pathname. On UNIX® systems, the fully qualified pathname can start with a tilde (~), signifying your home directory.

'newname' can be empty ([]), in which case the current name is used. If 'sys' refers to more than one block diagram, 'newname' must be a cell array of new names.

This command displays an error if you enter any of the following as the new model name:

Additional arguments must be supplied as name-value pairs, in any order. Allowed names are:

The same options are applied to all the block diagrams that are saved.

save_system returns the full name of the file that was saved, as a string. If multiple files were saved, the return value is a cell array of strings.

save_system can save only entire block diagrams, but the utility function Simulink.SubSystem.copyContentsToBlockDiagram can be used to copy the contents of a subsystem into a new block diagram, which can then be saved using save_system.

If you set the UpdateHistory property of the model to UpdateHistoryWhenSave, you see the following behavior:

Examples

This command saves the current system.

save_system

This command saves the vdp system with the name vdp.

save_system('vdp')

This command saves the vdp system to a file with the name 'myvdp'.

save_system('vdp', 'myvdp')

This command saves the vdp system to another directory.

save_system('vdp', 'C:\TMP\vdp.mdl')

This command saves the vdp system to a file with the name 'myvdp' and replaces links to library blocks with copies of the library blocks in the saved file.

save_system('vdp','myvdp','BreakLinks', true)

Both of these commands save the current model (with its current name), and break any library links in it:

save_system('mymodel,'mymodel','BreakLinks',true)
save_system('mymodel,[],'BreakLinks',true)

This command saves the current model with a new name, but displays an error (instead of saving) if something with this name already exists on the MATLAB path:

save_system('mymodel','mynewmodel','ErrorIfShadowed',true)

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 a MATLAB function.

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

This command saves the vdp system to Simulink Version R13SP1 with the name 'myvdp'. It does not replace links to library blocks with copies of the library blocks.

save_system('vdp','myvdp','SaveAsVersion','R13SP1')

This command saves the current model with a new name, saves the model workspace, breaks any library links, and overwrites if the file has changed on disk:

save_system('mymodel, 'mynewmodel', 'SaveModelWorkspace', 
true, 'BreakLinks',true, 'OverwriteIfChangedOnDisk', true)

This command returns the full path name of the file that was saved, as a string. If multiple files were saved, the return value is a cell array of strings.

filename = save_system('mymodel')

See Also

close_system, new_system, open_system

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS