MATLAB: Clearing functions selectively, excluding ones with persistent vars

clearclearing functionsMATLAB

Hi everyone,
I am having memory issues with version 7 (2004) and have to twist and twirl to get around it. I want to clear all the functions at some point, except ones that have persistent variables in them. I create an automatic list for those function names, and find the rest of the function names, but I cannot use the clear command to remove those functions from memory, due to type mismatch. Any ideas on this?
—> clear(setdiff(inmem,pers_fList)) % (pers_fList : function list to keep)
'setdiff' outputs cell array, which 'clear' does not accept. I can't convert it appropriately. Could there be a simple solution to this? Thanks !

Best Answer

Stephanie - try creating the cell array as
funcsToClear = setdiff(inmem,pers_fList);
and then clear it with
clear(funcsToClear{:});
I was able to do the above with a similar cell array of strings.