addSymbol - Add a symbol object definition to a C Function block - MATLAB (original) (raw)

Main Content

Add a symbol object definition to a C Function block

Syntax

Description

[mySymbol](#mw%5F69304037-7dec-4bae-8531-a30999870200) = addSymbol([mySymbolSpec](#mw%5Fe6dfcad1-88b0-4736-a2d9-d420d223bf99), [name](#mw%5F349dd983-1770-426e-b818-087e06dbd3d5)) creates a Symbol object,mySymbol, with the Name property specified byname and adds the symbol to the SymbolSpec object mySymbolSpec.

example

Examples

collapse all

Access and edit the properties of a symbol used in a C Function block.

Obtain the SymbolSpec object of the C Function block in your model using get_param. For example, select the C Function block in the model canvas and enter the following at the command line.

mySymbolSpec = get_param(gcb, 'SymbolSpec');

Use the addSymbol function to specify a new parameter symbol,myParam, in your C Function block code.

myParam = addSymbol(mySymbolSpec, 'myParam')

The Symbol object, myParam, uses default properties. Specify the scope of the symbol using the Scope property.

myParam.Scope = 'Parameter';

You can use the getSymbol function to access symbols specified for the block. For example, access the parameter symbol you added.

myParam = getSymbol(mySymbolSpec, 'myParam');

Edit the label of the parameter in the Block Parameters dialog box using theLabel property.

myParam.Label = 'Amplitude';

To delete a symbol from the SymbolSpec object, use thedeleteSymbol function.

deleteSymbol(mySymbolSpec, 'myParam');

Input Arguments

collapse all

Symbol specifications of C Function block, specified as a SymbolSpec object.

Name of the symbol, specified as a character vector.

Data Types: character

Output Arguments

collapse all

Symbol added to the C Function block, returned as a Symbol object. The Symbol object has default properties, except when you specify a name for the symbol in the input arguments. You can edit the properties of the Symbol object after creation.

Version History

Introduced in R2020a