MATLAB Answers

0

Clearing variables using a list of variable names

Asked by Omar Mian on 9 Dec 2011
Hello,
I have a cell array called 'varlist' that contains the names of variables that I want to clear from the workspace. What is the most efficient way of clearing these variables?
At the moment I am doing
for idx = 1:length(varlist)
clear(varlist{idx})
end
Can this be accomplished without resorting to a loop?
Thanks

  0 Comments

Sign in to comment.

Tags

Products

1 Answer

Answer by Omar Mian on 9 Dec 2011
 Accepted Answer

Just realised it was as simple as doing:
clear(varlist{:})

  0 Comments

Sign in to comment.