Reputation: 127
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.
subject = {'00001', '00002', '00003'}
EEG=poploadbv('C:/Users/M/Datasets',['01_',subject,'_Rest_','*.vhdr']);
I'm not that familiar with MatLab as I usually work in R, so any help is appreciated!
Upvotes: 0
Views: 103
Reputation: 106
Here is a simple loop in matlab:
subject = {'00001', '00002', '00003'};
for ii=1:length(subject)
curr_file = strcat('C:/Users/M/Datasets','01_',subject{ii},'_Rest_','*.vhdr');
% EEG=poploadbv(curr_file);
disp(curr_file);
end
I use the string concatenation function (strcat()
) to put your path and file together. Semicolons at the end of lines will suppress the printing to screen (e.g. subject = {'00001', '00002', '00003'};
with the semicolon will define subject but not print it)
Upvotes: 1