File Exchange

image thumbnail


version (7.27 KB) by Jan
Remove a field from a struct efficiently - fast C-Mex


Updated 20 Aug 2010

View License

fRMField: Remove field(s) from a struct - fast C-MEX
This function is about 5 to 10 times faster than RMFIELD of Matlab 2009a.

T = fRMField(S, Name)
S: Struct or struct array.
Name: String or cell string. Removing a name, which is not a field name
of S, is *not* an error here, in opposite to Matlab's RMFIELD.
T: Struct S without the removed fields.

S.A = 1; S.B = 2;
T = fRMField(S, {'B', 'C'}); % >> T.A = 1
T = fRMField(S, 'A'); % >> T.B = 2

TEST: Run TestfRMField to check validity and speed of the Mex function. See screenshot.

Tested: Matlab 6.5/2009a, WinXP 32bit, LCC2.4/3.8, BCC5.5, OpenWatcom1.8, MSVC2008
Compatibility to Linux, MacOS, 64bit, 2010a is assumed.

Cite As

Jan (2020). fRMField (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)


MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux