sf_fromworkspace (Simulink model) Open this Model

Loading MATLAB variables

The purpose of this demonstration is to illustrate how variables in your Stateflow chart can be defined and initialized from the MATLAB workspace. You are also able to select the 'Initialize From Workspace' property of the local variable.

In this particular example, we initialize two variables from the MATLAB workspace: 'gain' and 'delay'. The variables are initialized from the workspace by setting the 'Initialize From' property.

The 'gain' variable is used to determine the amplitude of the input sine wave and the 'delay' variable is used to suppress the output of the sine wave for a certain amount of time.

In this particular model, a graphical user interface (GUI) was also created using GUIDE to allow easy access to the variabls that are definied in the workspace. This is not necessary since the variables can simply be changed directly from the workspace. For example, changing the gain value to '9' using the GUI is equivalent to running the following command at the MATLAB command line:

>> gain = 9;