Text Import Error: Index exceeds matrix dimensions
    2 views (last 30 days)
  
       Show older comments
    
I am importing a number of text files and converting them to Matlab format using the code below (Note: the entire code is not included, just up to the portion where I am having issues). Most of them are running through just fine, but several (6 out of 20) are getting hung up. Below the code is the error message I am getting. I have scanned my files for inconsistencies between those that work and those that don't but cannot find any.
Can anyone see what I am missing/misunderstanding?
Thank you in advance for your help.
P.W.
% Scan file for locations of key parameters
loopdone=0;
count=1;
channamecount=0;
while loopdone==0
    currentcell=textscan(fileID,'%s',1,'delimiter', {'\n'});currentline=currentcell{1,1};        
%Load line of data
% search for Number of Channels
        if strncmp(currentline,'DM_NumLogChans=',15)==1
            numchan=str2num(currentline{1}(16:(length(currentline{1}))));        
        end
% search for Number of Data modes
        if strncmp(currentline,'DM_NumDataModes=',16)==1
            numdatamodes=str2num(currentline{1}(17:(length(currentline{1}))));   
        end
% search for channel names
        if strncmp(currentline,'DM_ChanName=',12)==1
            channamecount=channamecount+1;
            channameraw(channamecount,1)=currentline;   %extract channel name
        end
% search for Data start
        if strcmp(currentline,'DM_Start=')==1
            dataline=count+1;
            loopdone=1;                                 
        end
% search for Sample rate
        if strncmp(currentline,'DM_SampleRate=',14)==1
            samplerate=str2num(currentline{1}(15:(length(currentline{1}))));   
        end
          count=count+1;
      end
% cleanup channel names data
    begintext=strfind(channameraw, '@');
    endtext=strfind(channameraw, '.RN_');
      for count=1:length(channameraw)
          channame{count}=channameraw{count}(1,begintext{count}+1:endtext{count}-1);
      end
% Import Data
    rawimport = importdata(filename,'\t',dataline-1);
    numdatapoints=length(rawimport.data);
%Get serial Dates
      tempmat=char(rawimport.textdata(dataline:dataline+numdatapoints-1));
      for count=1:numdatapoints                       
          tempmat(count,11)=' ';                            
      end
Index exceeds matrix dimensions.
Error in edaq2mat (line 82)
                tempmat=char(rawimport.textdata(dataline:dataline+numdatapoints-1));
Answers (0)
See Also
Categories
				Find more on Dates and Time in Help Center and File Exchange
			
	Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
