Main Content

getGlobalNamesImpl

Class: matlab.System

Global variable names for MATLAB System block

Syntax

name = getGlobalNamesImpl(obj)

Description

name = getGlobalNamesImpl(obj) specifies the names of global variables that are declared in a System object™ for use in a Simulink® P-code file. For P-code files, in addition to declaring your global variables in stepImpl, outputImpl, or updateImpl, you must include the getGlobalNamesImpl method. You declare global variables in a cell array in the getGlobalNamesImpl method. System objects that contain these global variables are included in Simulink using a MATLAB System (Simulink) block. To enable a global variable in Simulink, your model also must include a Data Store Memory (Simulink) block with a Data Store Name that matches the global variable name.

Run-Time Details

getGlobalNamesImpl is called by the MATLAB System block.

Method Authoring Tips

You must set Access = protected for this method.

Input Arguments

expand all

System object handle used to access properties, states, and methods specific to the object. If your getGlobalNamesImpl method does not use the object, you can replace this input with ~.

Output Arguments

expand all

Cell array containing the global variable names. The elements of the cell array are character vectors.

Examples

expand all

Specify two global names in your class definition file.

methods(Access = protected)
    function glnames = getGlobalNamesImpl(obj)
      glnames = {'FEE','OTHERFEE'};
    end
    
    function y = stepImpl(obj,u)
      global FEE
      global OTHERFEE
      y = u - FEE * obj.lastData + OTHERFEE;
      obj.lastData = u;
    end
end

Version History

Introduced in R2016b