MATLAB: Need to delete all mat files from all the folders at the end of execution.

MATLAB

Hi, How can I delete all mat file at the end of execution For example my program consists as follows
Function mfile
statement...
function one
DataPath = [pwd '\01_data\001_data\'];
statement...
end
function two
DataPath = [pwd '\02_Data\'];
statement...
end
function three
DataPath = [pwd '\03_Data' '\'];
statement...
end
function four
DataPath = [pwd '\04_Data\'];
statement...
end
function five
statement...
end
end
  • cán anyone help me how to solve this

Best Answer

You should consider using onCleanup()