File Exchange

image thumbnail


version 1.0 (1.4 KB) by

Keep specified fields of a structure, discarding other fields.

1 Download


View License

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.

Comments and Ratings (1)

Omer Demirkaya

Saved my time! This is exactly what I needed.

MATLAB Release
MATLAB 7.0.1 (R14SP1)

Inspired by: keep

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

» Watch video