View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

4.0 | 1 rating Rate this file 4 Downloads (last 30 days) File Size: 1.4 KB File ID: #7031 Version: 1.0



Brett Shoelson (view profile)


01 Mar 2005 (Updated )

Keep specified fields of a structure, discarding other fields.

| Watch this File

File Information

ML provides a useful function RMFIELD to remove specified field(s) from a structure, but no corresponding function to KEEP specified field(s), removing the rest. This function addresses that discrepancy.

a = dir('*.m');
b = keepfield(a,{'name','date'});

This is an exceptionally short but useful piece of code.


Keep inspired this file.

MATLAB release MATLAB 7.0.1 (R14SP1)
Other requirements Tested in ver 6.01 and ver 7.04 sp2.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
15 Mar 2006 Omer Demirkaya

Saved my time! This is exactly what I needed.

Contact us