Effacer les filtres
Effacer les filtres

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

77 vues (au cours des 30 derniers jours)
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

Réponses (1)

Deep
Deep le 9 Juil 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.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by