publishmodel
R2026bDescription
Published models are ready-to-run versions of Simulink® models. They contain build artifacts that Simulink uses as needed. Simulink skips rebuild checks for published models, reducing model compilation and build overhead.
publishmodel( publishes the Simulink model specified by mdl)mdl to a published model file
(.slxp). By default, the function publishes the model with model
reference simulation support.
publishmodel(
specifies options using one or more name-value arguments. For example, you can specify the
supported functionality, output path, or supplemental files to include in the published
model.mdl,Name=Value)
Examples
To publish a model with default settings to the current folder, specify the model name.
publishmodel("mymodel")The function creates an SLXP file in the current folder. Models that reference the published model can simulate in normal, accelerator, or rapid accelerator mode.
To support C and C++ code generation for models that reference the published model, publish the model with model reference code generation support.
publishmodel("mymodel",SupportedFunctionality="model-reference-code-generation")
This function creates an SLXP file in the current folder. Models that reference the published model can generate C or C++ code and simulate in normal, accelerator, or rapid accelerator mode.
Input Arguments
Model name, path, or handle, specified as a string, character vector, or numeric handle.
Specify a model name, relative or absolute path, Model block handle, or model handle.
The model must be loaded or on the MATLAB® path.
Example: publishmodel("mymodel")
Data Types: char | string | double
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: publishmodel("mymodel",SupportedFunctionality=["model-reference-simulation","model-reference-code-generation"])
Custom tag for traceability, specified as a string or character vector.
Provide a custom tag that helps you trace the supported functionality in the
published model to a commit or job number. The tag supports printable and white space
characters, as defined by isstrprop.
The tag appears in the published model report and slxpinfo function output.
Example: publishmodel("mymodel",Tag="c123456@Project1:job567")
Data Types: char | string
Destination folder for published model, specified as a string or character vector.
Provide a relative or absolute path. If the specified path does not exist, the software attempts to create the path.
Example: publishmodel("mymodel",Path="C:/output")
Data Types: char | string
Output filename without the .slxp extension, specified as a
string or character vector. The filename must be a valid MATLAB variable name.
The filename and source model name can differ for published models.
To create multiple published models from the same source model, set
Filename to a unique filename each time you publish the model.
This approach lets you distribute published models that represent different
implementations, configurations, or revisions of the same source model.
Example: publishmodel("mymodel",Filename="mymodel_v2")
Data Types: char | string
Force overwrite of existing file, specified as a numeric or logical
1 (true) or 0
(false). When set to true, the function
overwrites an existing file with the same name.
Example: publishmodel("mymodel",ForcePublish=true)
Data Types: logical
Published model target types, specified as one of these values or a combination of these values:
"model-reference-simulation"— A model that references the published model can simulate in normal, accelerator, or rapid accelerator mode."model-reference-code-generation"— A model that references the published model can generate C and C++ code and simulate in normal, accelerator, or rapid accelerator mode. When you specify this option, the published model also supports"model-reference-simulation".
For the supported functionality you select, the published model contains the relevant build artifacts and dependencies. Simulink uses these build artifacts and does not rebuild them.
Example: publishmodel("mymodel",SupportedFunctionality="model-reference-code-generation")
Example: publishmodel("mymodel",SupportedFunctionality=["model-reference-simulation","model-reference-code-generation"])
Tunable parameters for simulation, specified as "all-tunable",
"none-tunable", or a string or cell array of character
vectors.
"all-tunable"— All tunable global parameters used by the model become tunable instance parameters of the published model."none-tunable"— No tunable global parameters used by the model become tunable instance parameters of the published model. The published model uses the parameter values at the time of publishing.String or cell array of character vectors — The specified tunable global parameters used by the model become tunable instance parameters of the published model.
Model arguments are inherently tunable. You do not need to specify the tunability of model arguments.
Example: publishmodel("mymodel",TunableParameters="none-tunable")
Data Types: char | string | cell
Option to preserve timestamps for traceability, specified as a numeric or logical
1 (true) or 0
(false).
false— Treat build artifacts as new when unpacking them from the published model by assigning current file system timestamps. If you generate code and build it using your own makefile or compiler, timestamp-based incremental builds use the newly extracted build artifacts.true— Preserve the original timestamps of build artifacts when unpacking them from the published model. This helps maintain traceability for verified build artifacts.
Example: publishmodel("mymodel",PreserveTimestamps=true)
Data Types: logical
Verbose output display, specified as a numeric or logical 1
(true) or 0 (false). When
set to true, the function displays detailed progress information
during publishing.
Example: publishmodel("mymodel",Verbose=true)
Data Types: logical
Supplemental files to include in the published model, specified as a string, character vector, or cell array of character vectors. Each file must exist on disk.
Specify supplemental files such as instructions, test results, and code coverage reports. You do not need to specify automatically identified model dependencies, such as data dictionaries. Publishing automatically includes these files. For more information about model dependencies, see Model dependencies.
Example: publishmodel("mymodel",SupplementalFiles="data.mat")
Data Types: char | string | cell
Block icon for the referenced published model, specified as one of these values:
"snapshot"— Use a snapshot of the model as the icon."off"— Do not include an icon. Instead, use the default Model block icon.File path — Specify a relative or absolute path to a
.pngimage file to use as the icon.
Example: publishmodel("mymodel",Icon="myicon.png")
Data Types: char | string
Version History
Introduced in R2026b
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)