File Exchange

image thumbnail


version 1.0 (1.14 KB) by

Keeps the specified variables and clears the rest. Allows the use of the wildcard *...



No License

This is another modified version of the original KEEP M-file by Xiaoning (David) Yang (1998). It allows the user to specify some variables and clear the rest, and uses the same syntax as the clear command. The main contribution of this code is that it allows the use of the wildcard * in exactly the same fashion as the clear command.

keep3 var1 var2
Clears all variables expect var1 and var2

keep3 va*2
Clears all variables expect those whose names begin with 'va' and end with '2'.

Requires Matlab 6.5 (R13) because it makes use of the regexp command.

Comments and Ratings (4)

Mark Thommy

A very useful script which builds on the ability of "keep". Has helped me a lot. Thanks to the author!

Carsten S

Excellent function!

yangcan gong


J Fav

very useful - just what I needed!

MATLAB Release
MATLAB 6.5 (R13)

Inspired by: keep

Inspired: Keep4

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

» Watch video