Keeps the listed variables in the calling workspace with a command format similar to "clear"
Updated 28 Aug 2006

View License

This is another version of Keep, which allows a user to specify what variables are kept in the workspace of the calling routine. "Keep" compliments "Clear".

This version has been extended to match the command format of the "clear" command for clearing variables. Thus wildcards and regular expressions are allowed. The version also supports the "global" key word and Keep will not touch global variables unless the "global" key word is used.

Examples of supported formats:
keep var1 var2
keep var*
keep -regexp expr1
keep global
keep global var1
keep global -regexp expr1

Cite As

Mirko Hrovat (2024). Keep4 (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Variables in Help Center and MATLAB Answers

Inspired by: keep, keep2, KEEP3

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Updated comments to improve code metrics.