Azzera filtri
Azzera filtri

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

77 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Deep
Deep il 9 Lug 2023
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.

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by