Main Content

rename

Rename specified variables in connected data source

Since R2024a

    Description

    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 connectionObj. The input arguments varNames and newVarNames must have the same dimensions.

    If the data connection can access 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.

    example

    Examples

    collapse all

    matFile = Simulink.data.connect("myMatFile.mat");
    matFile.ax = 3;
    success = rename(matFile,"ax","ay")
    success = 
    
    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, string array, 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, string array, 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