kpfield( S, fields )

Keep only specified fields in a structure. Inverse of rmfield.
77 Downloads
Updated 6 Apr 2016

View License

Function to keep only the specified fields in a structure. Quicker than using rmfield as structure is converted to a cell array before fieldnames are compared logically before converting back to a structure. Much quicker for large structures.

Cite As

Michael Sansoni (2025). kpfield( S, fields ) (https://uk.mathworks.com/matlabcentral/fileexchange/56413-kpfield-s-fields), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Structures in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0