Text Import Error: Index exceeds matrix dimensions

조회 수: 2 (최근 30일)
Pw
Pw 2014년 2월 14일
편집: Pw 2014년 3월 26일
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));

답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by