Main Content

load_system

R2026b

Load Simulink model into memory

Description

h = load_system(sys) loads the model sys into memory and executes preload and load callbacks defined in the model. After you load a model into memory, you can work with the model programmatically using Simulink® APIs. To save changes to the model, use the save_system function.

Note

Security Considerations: Before loading, opening, or simulating a model, consider whether you trust the source or author of the model. Models from untrusted sources might contain callbacks and custom blocks that execute unexpected code when you load, open, or simulate the model. Untrusted sources include those you clone from a remote repository, download, or receive as an archive.

For information about callbacks, see Customize Model Behavior with Callbacks.

Loading a model does not open the model in the Simulink Editor. To open the model, use the open_system function.

example

Examples

collapse all

Suppose you have a model named myModel. Load the model into memory and return the model handle.

h = load_system("myModel");

Check that the model is loaded using the bdIsLoaded function. If the model is loaded, the function returns 1. If the model is not loaded, the function returns 0.

bdIsLoaded("myModel")
ans =
  logical
   1

Input Arguments

collapse all

Systems to load, specified as one or more handles or model names. Format the handles as numeric scalars or numeric arrays. Format the names as strings, string arrays, character vectors, or cell arrays of character vectors. Do not specify file extensions in the names.

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

Example: "myModel"

Example: ["myModel1";"myModel2"]

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

Output Arguments

collapse all

Handle of loaded model, specified as a numeric scalar or array.

Data Types: double | array of doubles

Version History

Introduced before R2006a

expand all