フィルターのクリア

How to delete temp files generated by simulink at the end of each iteration of a for loop?

77 ビュー (過去 30 日間)
Francesco
Francesco 2023 年 7 月 9 日
回答済み: Deep 2023 年 7 月 9 日
Hi to everyone!
I'm running a lot of simulink simulation model through a for loop. At the end of the for loop I want to clear the temporany file folder because after a few iterations it fills up the memory of my C drive. Can someone help me please? Thankyou in advance

回答 (1 件)

Deep
Deep 2023 年 7 月 9 日
for i = 1:n
% Run your Simulink model here...
% Get system's temporary directory.
% Use 'cacheFolder = pwd;' instead to delete .slxc files in the current path.
cacheFolder = tempdir;
files = dir(fullfile(cacheFolder, '*.slxc')); % Look for Simulink cache files
for j = 1:length(files)
delete(fullfile(files(j).folder, files(j).name)); % Delete each file
end
end
When working on this, double-check the path and maybe do a dry-run with displaying the files that would be deleted before actually deleting anything.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by