Main Content

deleteGlobalArg

R2026b

Class: Simulink.CustomCode.FunctionPortSpecification
Namespace: Simulink.CustomCode

Selectively delete global arguments from C Caller block

Since R2024b

Description

CCallerObj.deleteGlobalArg(globalArgumentName) deletes global arguments from a C Caller block. The CCallerObj is an object of class FunctionPortSpecification. To use this function in Simulink®, navigate to Configuration Parameters > Simulation Target > Import settings and check that the Automatically infer global variables as function interfaces check box is not selected. Alternatively, from the command line, use the set_param function and set CustomCodeGlobalsAsFunctionIO to off for the corresponding block. For more information, see Automatically infer global variables as function interfaces

example

Input Arguments

expand all

Name of the global argument you want to delete from the block, specified as a character vector or string scalar.

Examples

expand all

Selectively delete global arguments from a C Caller block.

Replace mdlName with the name of your model. Using this command, you can check whether the Automatically infer global variables as function interfaces parameter is selected or not selected.

get_param(mdlName,'CustomCodeGlobalsAsFunctionIO')

If the get_param function returns 'off', skip the next step.

If the get_param function returns 'on', use this command to disable automatic deletion of global arguments. This setting allows you to use the deleteGlobalArg function to select the global arguments you want to delete.

set_param(mdlName,CustomCodeGlobalsAsFunctionIO="off");

Obtain a FunctionPortSpecification object from the C Caller block (indicated as gcb) in your model using the get_param function. Select the block in your model canvas and enter this command at the MATLAB® command line.

CCallerObj = get_param(gcb,'FunctionPortSpecification');

Use the deleteGlobalArg method to delete global arguments from the C Caller block. You can replace myGlobalArg with a global argument you want to use in your model.

CCallerObj.deleteGlobalArg('myGlobalArg');

Version History

Introduced in R2024b