|On this page…|
A SimState does not include information about these elements:
Persistent data in custom C code
Persistent data in external MATLAB® code
Therefore, you cannot modify the values of those elements.
These rules apply when you modify data values:
You cannot change the data type or size. Scalar data must remain scalar. Vector and matrix data must keep the same dimensions. The only exception to this rule is Stateflow® data of ml type (see ml Data Type for details).
For enumerated data types, you can choose only enumerated values from the type definition. For other data types, new values must fall within the range that you specify in the Minimum and Maximum parameters.
Use one-based indexing to define rows and columns of a matrix.
Suppose that you want to change the value of an element in a 21-by-12 matrix. To modify the element in the first row and second column, type:
c.state_name.data_name.Value(1,2) = newValue;
These rules apply when you use the setActive method on an exclusive (OR) leaf state:
State-parented local data does not reinitialize.
The newly active state does not execute any entry actions. Similarly, the previously active state does not execute any exit actions.
If you want these state actions to occur, you must execute them separately. For example, if your state actions assign values to data, you must assign the values explicitly.
The setActive method tries to maintain state consistency by:
Updating state activity for parent, grandparent, and sibling states
Resetting temporal counters for newly active states
Updating values of state output data (read-only)
Enabling or disabling function-call subsystems and Simulink® functions that bind to states
The highlightActiveStates method also executes when these conditions are true:
The model is open.
The chart is visible.
The highlightActiveStates method has executed at least once, but not the removeHighlighting method.
After you load a SimState for a continuous-time chart, you can restart simulation from a nonzero time. However, you cannot modify the state activity or any data values, because the SimState for a continuous-time chart is read-only. For more information, see Summary of Rules for Continuous-Time Modeling.
When you load a SimState, the complete simulation state is available as a variable in the MATLAB base workspace. You cannot perform partial loading of a SimState for a subset of chart objects.
Use the clone method to copy an entire SimState to a new variable (see Methods for Interacting with the SimState of a Chart). You cannot copy a subset of SimState values, because the clone method works only at the chart level.
Suppose that you obtain a handle to the SimState of your chart using these commands:
blockpath = 'model/chart'; c = xFinal.getBlockSimState(blockpath);
Assignment statements such as stateCopy = c.state, dataCopy = c.data, and simstateCopy = c do not work. These assignments create copies of object handles, not SimState values.
For a list of SimState limitations that apply to all blocks in a Simulink model, see Limitations of the SimState.