How to flush out all variables before each iteration
Show older comments
Hi,
I have 100 iterations, 50~100 variables. I want to flush out all variables before each iteration. I am doing now like variable1=[];variable2=[] ---variable100=[];. But I want to know is there any command which can do this in a single command.
many thanks in advance,
1 Comment
Stephen23
on 8 May 2016
100 variables! That is a poor way to write code. You should put all of your variables in a structure: this would be easier to manage, and makes tasks like this trivial.
Accepted Answer
More Answers (1)
Ahmet Cecen
on 8 May 2016
Without more information, no way for me to suggest a better way to do this, but check:
clearvars -except VarYouwantToKeep1 VarYouwantToKeep2
assuming you want to flush more variables than you want to keep...
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!