Main Content

deleteGlobalArg

Selectively delete global arguments from C Caller block

Since R2024b

    Description

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

    example

    Examples

    collapse all

    This function enables you to 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 previous step returns 'off', skip this step and move to the next one.

    If the previous step returns 'on', use this command to disable automatic deletion of global arguments. This enables you to use deleteGlobalArg function to delete the global arguments you want to delete.

    set_param(mdlName,'CustomCodeGlobalsAsFunctionIO','off');

    Then obtain FunctionPortSpecification object of the C Caller block in your model. To do so, select the block in your model canvas and enter this command at the MATLAB® command line.

    CCallerObj = get_param(gcb,'FunctionPortSpecification');

    Use the deleteGlobalArg function 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');

    Input Arguments

    collapse all

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

    Data Types: char | string

    Version History

    Introduced in R2024b