Code covered by the BSD License  

Highlights from
keepfield

4.0

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

keepfield

by Brett Shoelson

 

01 Mar 2005 (Updated 03 Mar 2005)

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

The author wishes to acknowledge the following in the creation of this submission:
keep

MATLAB release MATLAB 7.0.1 (R14SP1)
Other requirements Tested in ver 6.01 and ver 7.04 sp2.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
15 Mar 2006 Omer Demirkaya

Saved my time! This is exactly what I needed.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
structures Brett Shoelson 22 Oct 2008 07:42:27
cell arrays Brett Shoelson 22 Oct 2008 07:42:27
keep Brett Shoelson 22 Oct 2008 07:42:27
field Brett Shoelson 22 Oct 2008 07:42:27
structure Brett Shoelson 22 Oct 2008 07:42:27
rmfield Brett Shoelson 22 Oct 2008 07:42:27
utilities Brett Shoelson 22 Oct 2008 07:42:27

Contact us at files@mathworks.com