dlmread reading outside of range

조회 수: 1 (최근 30일)
Jacob
Jacob 2012년 7월 26일
Hello all,
I am trying to read a file like the following:
1 0 100 0.0 -100 .5 10 10
2 1 200 0.5 -100 .5 10
3 2 300 1.0 -100 .5 10 *
4 3 400 1.5 -100 .5 10 *
but I only want columns 2 - 7, so I have a loop for the dlmread with the parameters
num(k,:)=dlmread(FullFileNames(j,:),'',[count(j,1)+4+k 1 count(j,1)+4+k 6]);
where it goes row by row. I get the error
??? Error using ==> dlmread at 145
Mismatch between file and format string.
Trouble reading number from file (row 1, field 8) ==> * \n
Error in ==> DragTestGUI>run_button_Callback at 284
num(k,:)=dlmread(FullFileNames(j,:),'',range);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> DragTestGUI at 44
gui_mainfcn(gui_State, varargin{:});
Error in ==>
guidemfile>@(hObject,eventdata)DragTestGUI('run_button_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
Which means it is reading one row beyond what I want it to. Any ideas on how to fix this?
FYI: the code is running under a GUI, hence the last part of the error.

채택된 답변

Walter Roberson
Walter Roberson 2012년 7월 26일
dlmread() can only be used for pure numeric data. Use textscan() instead.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by