Borrar filtros
Borrar filtros

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

77 visualizaciones (últimos 30 días)
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

Respuestas (1)

Deep
Deep el 9 de Jul. de 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.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by