Main Content

slwebview

Export Simulink models to web views

Description

slwebview starts the web view dialog box in the Report Explorer.

filename = slwebview(sysname) exports the subsystem system_name and its child systems to the file filename. The model that contains the subsystem must be open.

example

filename = slwebview(folder) exports all models in a folder. See RecurseFolder to include models in subfolders.

filename = slwebview(sysname,Name=Value) provides additional options specified by one or more name-value arguments.

example

Examples

collapse all

Open the sldemo_fuelsys model.

openExample("sldemo_fuelsys")

Export the Engine Gas Dynamics subsystem and the system that contains it to a web view. Do not export the subsystems that it contains.

fuelsys_web_view = slwebview("sldemo_fuelsys/Engine Gas Dynamics", ...
    SearchScope="CurrentAndAbove")

Navigate to the Engine_Gas_Dynamics folder and open webview.html.

Web view showing the Engine Gas Dynamics subsystem.

For more information, see Display and Navigate Through Web Views.

Open the sldemo_fuelsys model.

openExample("sldemo_fuelsys")

Export the model to a web view and allow access to the models it references.

fuelsys_web_view = slwebview("sldemo_fuelsys", ...
    "FollowModelReference","on")

Navigate to the sldemo_fuelsys folder and open webview.html. For more information, see Display and Navigate Through Web Views.

Click the fuel_rate_control block to see the block properties. Double-click the block to display the referenced model.

Web view showing the sldemo_fuelsys model.

Input Arguments

collapse all

System to export to the web view file, specified as a character vector or string scalar that contains the path to the system or a handle to a subsystem, block diagram, chart, or subchart. By default, the function also exports the child systems of the sysname system. Use the SearchScope name-value argument to export other systems, in relation to sysname.

Example: "sysname"

Path to the file folder containing one or more models to export to a web view file, specified as a character vector or string scalar. The function exports all the models in the folder.

Name-Value Arguments

collapse all

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.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: htmlFileName = slwebview(gcs,"LookUnderMasks","all",... "FollowLinks","on") Export to a web view all layers of the model hierarchy to which the current system belongs, including the ability to interact with library links and masks.

Systems to export, relative to the sysname system, specified as one of these values:

  • "CurrentAndBelow" — Exports the Simulink® system or the Stateflow® chart specified by sysname and all systems or charts that it contains.

  • "Current" — Exports only the Simulink system or the Stateflow chart specified by sysname.

  • "CurrentAndAbove" — Exports the Simulink system or the Stateflow chart specified by the sysname and all systems or charts that contain it.

  • "All" — Exports all Simulink systems or Stateflow charts in the model that contains the system or chart specified by sysname.

Data Types: char | string

Whether to export masked blocks, specified as one of these values:

  • "none" — Does not export masked blocks in the web view. Masked blocks are included in the exported systems, but you cannot access the contents of the masked blocks.

  • "all" — Exports all masked blocks.

Data Types: char | string

Whether to include behavior components defined in architecture models, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • "on" — Includes behavior components in the web view

  • "off" — Does not include behavior components in the web view

Whether to include user notes, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • "on" — Includes user notes in the web view

  • "off" — Does not include user notes in the web view

Whether to export supporting MATLAB functions used in MATLAB Function blocks or Stateflow charts, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • "on" — Exports supporting functions or charts in the web view

  • "off" — Does not export supporting functions or charts in the web view

Whether to access referenced models, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • "on" — Includes referenced models in the web view

  • "off" — Does not include referenced models in the web view

Since R2024b

Whether to export referenced subsystems, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • "on" — Exports referenced subsystems in the web view

  • "off" — Does not export referenced subsystems in the web view

Whether to export models in subfolders, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState..

  • "on" — The web view includes models in the top-level folder and models in subfolders

  • "off" — The web view includes models only in the top-level folder and does not include models in subfolders

This property applies only if you specify a folder as an input argument.

Name of the web view output package, specified as a character vector or string scalar. The web view output is a ZIP file or folder of unzipped web view files, or both types of outputs. The default value of PackageName is the model name.

Data Types: char | string

Path in which to place the packaged web view, specified as a character vector or string scalar. To save the packaged web view in the same folder as the model, use $model as the PackageFolder. The default value of PackageFolder is the current working directory.

Data Types: char | string

Type of web view output package, specified as one of these values:

  • "both" — Creates both zipped and unzipped output

  • "zipped" — Creates a ZIP file with an .htmx extension

  • "unzipped" — Creates a folder of files

Data Types: char | string

Optional views to include, specified as a cell array that contains one or both of these values:

  • "requirements"

  • "coverage"

See Include Model Requirements and Coverage Data in Web Views.

Data Types: cell

Whether to display the web view in a web browser after you export the web view, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • "on" — Displays the web view in a web browser when you export the web view

  • "off" — Does not display the web view in a web browser when you export the web view

Whether to display the status bar when you export the web view, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • "on" — Displays the status bar when you export the web view

  • "off" — Does not display the status bar when you export the web view

Whether to export the model incrementally, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.

  • "on"slwebview reuses cached web views.

    • slwebview reuses cached web views for the top-level model that have no changes since the last usage of slwebview.

    • If FollowModelReference or FollowSubsystemReference is also set to "on", slwebview also reuses cached web views for referenced models or subsystems that have no changes since the last usage of slwebview.

  • "off"slwebview regenerates all previously exported web views.

slwebview only regenerates web views for changes that dirty the model. Changes to model behavior or model appearance that do not dirty the model do not trigger web view regeneration. For example, changing the name of a tunable parameter dirties the model, but changing the value of a tunable parameter does not dirty the model. To force a web view to regenerate, delete the simulation cache file of the model in the current simulation cache folder.

Tip

slwebview caches web views in the current simulation cache folder. To reuse existing web views, use a common simulation cache folder for web view export.

Data Types: logical

Output Arguments

collapse all

Name of HTML file that displays the web view, returned as a character vector. Exporting a web view creates the supporting files in a folder.

Tips

  • A web view is an interactive rendition of a model that you can view in a web browser. You can navigate a web view hierarchically to examine specific subsystems and to see properties of blocks and signals.

    You can use web views to share models with people who do not have Simulink installed.

    Note

    When using color to differentiate sample times, only the colors for referenced models are visible in the web view. Colors applied to referenced subsystems are not supported.

  • To generate a web view when running MATLAB with the -batch startup option on Linux® machines:

    1. Create a Linux shell file.

    2. In the shell file, store the commands that open the model and generate the web view in a variable. You can enter multiple semicolon-separated commands.

    3. In the shell file, use xvfb-run to run MATLAB with the -batch startup option and execute the commands. For more information about xfvb-run, see xvfb-run on the Ubuntu website.

    4. Save the shell file to a directory on the MATLAB path.

    5. In a Linux terminal, navigate to the directory that contains the shell file.

    6. Execute the shell file.

    This example code defines a Linux Bash shell that executes slwebview for the model myModel.

    #!/bin/bash
    
    MATLAB_COMMANDS="open_system("myModel.slx"); 
    slwebview("myModel.slx");"
    xvfb-run matlab -batch "$MATLAB_COMMANDS exit;"

Version History

Introduced in R2006a

expand all