Loading files with different names in MatLab
조회 수: 12 (최근 30일)
이전 댓글 표시
I'm trying to read .vhdr files into MatLab in a loop function, but they all contain a different date in the filename. How can I get this to work? It's in the structure below where it starts with '01_' then has the subject number '####', then 'rest' and then the date of collection '02202021' then the .vhdr filetype.
File name structure: '01_####_rest_02202021.vhdr'
I have defined my subject numbers above in a variable called subject.
Such as:
subject = {'00001', '00002', '00003'}
EEG=poploadbv('C:/Users/M/Datasets',['01_',subject,'_Rest_','*.vhdr']);
댓글 수: 0
답변 (1개)
Jan
2021년 4월 2일
Do you want to load all files inside a folder?
Folder = 'C:/Users/M/Datasets';
FileList = dir(fullfile(Folder, '*.vhdr'));
Data = cell(1, numel(FileList));
Subject = cell(1, numel(FileList));
for iFile = 1:numel(FileList)
FileName = FileList(iFile).name;
File = fullfile(FileList(iFile).folder, FileName);
Data{iFile} = poploadbv(File);
tmp = splitstr(FileName, '_';)
Subject{iFile} = tmp{2};
end
댓글 수: 5
Image Analyst
2021년 4월 8일
I believe using two stars :
Folder = 'C:/Users/M/Datasets';
FileList = dir(fullfile(Folder, '**/*.vhdr'));
should work. Does it not?
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!