Main Content

Stateflow.exportAsClass

Export MATLAB class for standalone chart

Since R2019b

Description

example

Stateflow.exportAsClass(source) saves a standalone Stateflow® chart as a MATLAB® class file in the current folder. The saved file has the same name as the chart. For example, if source is chart.sfx, the function saves the MATLAB class in the file chart.m.

example

Stateflow.exportAsClass(source,destination) saves the chart as a MATLAB class file in the folder destination.

Note

The MATLAB class produced by Stateflow.exportAsClass is intended for debugging purposes only, and not for production use or manual modification. For more information, see Tips.

Examples

collapse all

Save Stateflow chart chart.sfx as the MATLAB class file chart.m in the current folder.

Stateflow.exportAsClass("chart.sfx");

Save Stateflow chart chart.sfx, which is located in folder dir1, as the MATLAB class file chart.m in the current folder.

Stateflow.exportAsClass(fullfile("dir1","chart.sfx"));

Save Stateflow chart chart.sfx, which is located in the current folder, as the MATLAB class file chart.m in the folder dir2.

Stateflow.exportAsClass("chart.sfx","dir2");

Input Arguments

collapse all

Path and file name of a standalone chart, specified as a string scalar or character vector. You can use the absolute path from the root folder or the relative path from the current folder. Standalone charts have the extension .sfx.

Data Types: char | string

Path of the destination folder for the MATLAB class file, specified as a string scalar or character vector. You can use the absolute path from the root folder or the relative path from the current folder. If not specified, the function saves the MATLAB script file in the current folder.

Data Types: char | string

Tips

  • Use the code produced by Stateflow.exportAsClass to debug run-time errors that are otherwise difficult to diagnose. For example, suppose that you encounter an error while executing a Stateflow chart that controls a MATLAB application. If you export the chart as a MATLAB class file, you can replace the chart with the class in your application and diagnose the error by using the MATLAB debugger.

    Note

    Error messages produced by the MATLAB class point to different line numbers than the corresponding error messages produced by the Stateflow chart.

  • When you execute the MATLAB class produced by Stateflow.exportAsClass, the Stateflow Editor does not animate the original chart.

Version History

Introduced in R2019b