dlmread reading outside of range
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Walter Roberson
on 26 Jul 2012
dlmread() can only be used for pure numeric data. Use textscan() instead.
0 Comments
More Answers (0)
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!