Filter löschen
Filter löschen

how can i clear the variables except the ones i need inside a loop

185 Ansichten (letzte 30 Tage)
Domenico Gabriele
Domenico Gabriele am 12 Sep. 2016
Bearbeitet: Saurabh Gupta am 19 Sep. 2016
i need to run some scripts inside a loop in order to make a parametric study on some variables inside the scripts. At each iteration i need to change the input variables for the script, save the variables of interest in an array and clear all the others.

Antworten (1)

Saurabh Gupta
Saurabh Gupta am 19 Sep. 2016
Bearbeitet: Saurabh Gupta am 19 Sep. 2016
Hello Domenico,
You can use the clearvars command, with the -except option, to clear all the variables except the ones you need. You will have to specify the required variables by using either their names or regular expressions (with the -regexp option).
For more details and examples, refer to the attached MATLAB documentation page.

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by