As lots of users reported above, new versions of matlab support the following command dir('**/*.mat');
However, old versions of matlab don't support this.
Instead of writing a large code, inspect the structure field "isfield" and so on, you could just easily ask DOS (or the command prompt) to do it for you. The output from MS-DOS isn't formatted, so you will need to split the one block string to separate lines
newline = char(10);
[~,all_mats] = system('dir /s /b *.*');
all_mats = strsplit(all_mats,newline)';