Main Content

rename

Rename specified variables in connected data source

Since R2024a

    Description

    example

    rename(connectionObj,varNames,newVarNames) changes the name of each specified variable in varNames to its corresponding new variable name in newVarNames in the connected data source. The input arguments varNames and newVarNames must have the same dimension.

    If the data connection can see multiple definitions of the same variable (for example, in a data dictionary and in a referenced dictionary), the function renames all visible definitions of the variable.

    Examples

    collapse all

    dd = Simulink.data.connect('myDictionary.sldd', TabComplete = 'Vars');
    dd.ax = 3;
    success = rename(dd, 'ax', 'ay')
    logical
        1
    dd = Simulink.data.connect('myDictionary.sldd', TabComplete = 'Vars');
    dd.ax = 3;
    dd.ay = 4;
    success = rename(dd, {'ax', 'ay'}, {'bx', 'by'})
    
    1x2 logical array
        1    1

    Input Arguments

    collapse all

    Connection to data source, specified as a Simulink.data.DataConnection object.

    Variable names, specified by a string, character vector, array of strings, or cell array of character vectors. The variable names must exist in the connected data source or the function returns 0 (false).

    New variable names, specified by a string, character vector, array of strings, or cell array of character vectors. The order of the new variable names corresponds to the order of the current variable names in varNames. The new variable names must not exist in the connected data source or the function returns 0 (false).

    Version History

    Introduced in R2024a