Hi there, I would like to read information from a file into an array for later use. Only certain rows of that file are supposed to be read in, namely rows for which the second column starts with 'S1' and is followed by two random digits. I'm having trouble with this conditional textscan. Here is the code for reading in the file (note that it starts with 13 lines that are not in column format, hence the "headline" codes at the beginning). I basically want the varibales Postion, Length, Channel etc only to be read in for lines that meet the regex condition.
dataFileName=strcat('EEG_Anne_',int2str(pNumber),'.vmrk');fid = fopen(dataFileName);headline1=fgets(fid);headline2=fgets(fid);headline3=fgets(fid);headline4=fgets(fid);headline5=fgets(fid);headline6=fgets(fid);headline7=fgets(fid);headline8=fgets(fid);headline9=fgets(fid);headline10=fgets(fid);headline11=fgets(fid);headline12=fgets(fid);headline13=fgets(fid);C = textscan(fid, '%s%s%d%d%d','Delimiter',',');Stimulus=C{2};if regexp(Stimulus{i},'S1\d*'), Type=C{1}; Position=C{3}; Length=C{4}; Channel=C{5}; endfclose(fid);
Best Answer