Matlab traverses all files in the folder

Matlab traverses all files in the folder

function [names,class_num] = GetFiles(SamplePath1 )
SamplePath1 = 'C:\Users\Administrator\Desktop\CDG\';
files = dir(SamplePath1);
size0 = size(files);
length = size0(1);

for i=3:length;
   fileName = strcat(SamplePath1,files(i,1).name); 
   names(:,:,i-2) = fileName;
end
class_num = size(names);
end

Insert picture description here

Guess you like

Origin blog.csdn.net/qestion_yz_10086/article/details/108252712