Clear all variables in MATLAB workspace of certain type

Alec Jacobson

May 03, 2012

weblog/

Here's a snippet to clear all variables of a certain class in your matlab workspace:
D = whos();
D = D(arrayfun(@(d) strcmp(d.class,'yourclassname'),D));
clear(D.name)