Main Content

getPersistentVariables

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

Since R2022a

Description

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

example

Examples

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.

  1. Get persistent variable values from target computer tg.

    myPersist = getPersistentVariables(tg)
    myPersist =
    
         []
  2. 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
    myPersist = 
    
      struct with fields:
    
        Variable1: 10
        Variable2: [2×2 int8]
  3. Set the persistent variable values on the target computer. Get the variables from the target computer.

    setPersistentVariables(tg,myPersist)
    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