renameStructField
Rename field names of a struct or struct array.
📝Syntax
stOut = renameStructField(stIn, newNames)
stOut = renameStructField(stIn, oldNames, newNames)
📥Input Arguments
Parameter Description
stIn A struct or struct array.
newNames a row vector characters, string array or cell array of strings representing the new field names. When used as the second argument, it must have the same number of elements as the number of fields in stIn.
oldNames a row vector characters, string array or cell array of strings representing the existing field names to rename. Ignored silently if the field name is not present in stIn.
📤Output Arguments
Parameter Description
stOut A struct or struct array.
📄Description

renameStructField renames the field names of a struct or struct array.

It supports renaming all field names at once or renaming selected field names individually.

💡Examples
date_st = struct('day', 15, 'month' ,'August','year', 1974)
date_st = renameStructField(date_st, {'Day', 'Month', 'Year'})
date_st = struct('day', 15, 'month' ,'August','year', 1974)
date_st = renameStructField(date_st, 'day', 'jour')
🔗See Also
structrmfield
🕔Version History
Version Description
1.15.0 initial version
Edit this page on GitHub