Code covered by the BSD License  

Highlights from
keepfield

4.0

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

keepfield

by

 

01 Mar 2005 (Updated )

Keep specified fields of a structure, discarding other fields.

| Watch this File

File Information
Description

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.

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

This is an exceptionally short but useful piece of code.

Acknowledgements

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