MATLAB: How to delete ‘mat ‘files

MATLAB

Hi, I have 20 files with '.dat' and '.mat' extension in one folder. And I have problem with deleting files with extension '.mat'. I have written this in order to delete mat files
delete(any(size(dir(['DataPath/*.mat' ]),1)))
after deleting one '.mat ' it showing error
Error using delete
Argument must contain a string.
Error in myfile(line 81)
delete(any(size(dir(['DataPath/*.mat' ]),1)))
Can any one please tell me how to solve this problem

Best Answer

DataPath = 'C:\Blah\User\Blah';
delete(fullfile(DataPath, '*.mat'))