Main Content


Get persistent variables from the Simulink Real-Time target computer to MATLAB



variables_struct = getPersistentVariables(target_object) gets persistent variables values from the persistent variables on the target computer and places these values into a structure of MATLAB variables on the development computer.


collapse all

The getPersistentVariables function and setPersistentVariables function enable you to access persistent variables that are created and updated in the real-time application by using the Persistent Variable Read block and Persistent Variable Write block.

Get persistent variable values from target computer tg.

myPersist = getPersistentVariables(tg)
myPersist =


Change the value of Variable1 in the myPersist structure. Add Variable1 to the structure.

myPersist.Variable1 = 10;
myPersist.Variable2 = int8([1, 2; 3, 4]);
myPersist = 

  struct with fields:

    Variable1: 10
    Variable2: [2×2 int8]

Set the persistent variable values on the target computer. Get the variables from the target computer.

myMorePersist = getPersistentVariables(tg)
myMorePersist = 

  struct with fields:

    Variable1: 10
    Variable2: [2×2 int8]

Input Arguments

collapse all

Provides access to methods that manipulate the target computer properties.

Example: tg

Output Arguments

collapse all

Stores persistent variables from the target computer in a structure on the development computer.

Example: myPersist

Version History

Introduced in R2022a