files=dir('*.txt'); #creates struct with all files filesarray = struct2cell(files); #converts struct array to cell array names=filesarray(1,:) #extracts first row of cell array (all file names) and assigns to names for i=1:length(names) eval(['load ' files(i).name ' -ascii']) end