MATLAB: Simply Directory Question

directory

Hello All,
Quick question, I am trying to load all files from a folder that have a .m ext:
folder = C:\Users\ecorbett\Documents\MATLAB\UI\VCoachData\0005_Capture_10072009\AccelData
files = dir(folder)
I know I need to include something like '*.m' in dir but I dont know the correct syntax to do so. Can someone help me with this?

Best Answer

m=dir([folder '\*.m']);
files=arrayfun(@(x)m(x).name,1:numel(m),'uni',false); %or use Oleg suggestion