RenameField - Rename a fields of a struct
T = RenameField(S, Old, New)
S: Struct or struct array.
Old: String or cell string, name of the field to be renamed.
New: String or cell string, new field name, which must be a valid Matlab symbol.
T: Struct S with renamed fields.
S.A = 1; S.B = 2;
T = RenameField(S, 'B', 'C'); % >> T.A = 1, T.C = 2
This function was created after a discussion in Loren's blog:
Tested: Matlab 6.5/2009a, WinXP 32 bit, LCC2.4/3.8, BCC5.5, OpemWatcom 1.8, MSVC 2008
Compatibility to 64 bit, Linux, MacOS is assumed.
Look in the C-file for instructions to compile the Mex file at first.
A slower M-version is included, but disabled by a call to ERROR. The M-version does not check the validity of the new names.