kpfield( S, fields )

Keep only specified fields in a structure. Inverse of rmfield.

You are now following this Submission

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 (2026). kpfield( S, fields ) (https://uk.mathworks.com/matlabcentral/fileexchange/56413-kpfield-s-fields), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0