MATLAB: How to import multiple txt files into MATLAB.

filename import

My files are organized as such:
P14_LG_1 P14_MD_1 P14_SM_1
P14_LG_2 P14_MD_2 P14_SM_2
P14_LG_3 P14_MD_3 P14_SM_3
this continues for participants 14 to 27, if I was simply loading based on just the participant number I believe that I would do something like this
folderPath = 'F:\';
participantNumber = [14:27]
myDATA = cell (1, (numel(participantNumber)));
for pn = 1: numel(participantNumber);
fileName = ['P' , num2str(participantNumber(pn))];
data = importfile ([folderPath, fileName]);
end

Best Answer

folderPath = 'F:\';
participantNumber = [14:27]
myDATA = cell (1, (numel(participantNumber)));
for pn = 1: numel(participantNumber);
fileName = fullfile( folderPath, sprintf('P%d', participantNumber(pn)) );
data{pn} = importfile(fileName);
end