Memory during a loop
古いコメントを表示
Hi,
If I run Clear All during a loop, will it also clear the loop value?
Thanks,
採用された回答
その他の回答 (2 件)
Arthur
2012 年 9 月 6 日
sure, you can just clear the variable:
clear varname
check:
doc clear
3 件のコメント
Aadil
2012 年 9 月 6 日
Arthur
2012 年 9 月 6 日
Do you need to load all the variables at once? You can also load a single variable at the time.
S = load(filename, variables)
This can be more memory efficient, but you may have to open the file multiple times...
Jan
2012 年 9 月 6 日
+1. Especially the suggested "S=load()" is a very good idea.
Sean de Wolski
2012 年 9 月 6 日
編集済み: Sean de Wolski
2012 年 9 月 6 日
It depends on where you call it, compare:
- 1
for ii = 1:10
ii
clear all
end
- 2
for ii = 1:10
clear all
ii
end
But of course Arthur is right - you shouldn't need to use clear all at all.
2 件のコメント
Aadil
2012 年 9 月 6 日
Sean de Wolski
2012 年 9 月 6 日
Assign the *.MAT file you load to a variable then clear it when you're done. That way you aren't poofing variables into your workspace.
for ii = stuff
S = load('mymatfile.mat');
do_stuff_with(S)
clear S
end
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!