dlmread not working as expected...
3 views (last 30 days)
Show older comments
%This is my file (and also the expected output):
%0 0.334 12:54:00 9.3 -54
%0.22 0.592 13:06:00 5.2 -22
%...........................
M = dlmread(filename.txt);
disp(M);
My current code does not display the expected output.
I have also tried M = dlmread(filename.txt,' '); to specify space delimiters but it returns an error "Mismatch between file and format string. Trouble reading number from file (row 1, field 4) ==> :54:0"
I believe all my values are numeric, since disp(class(12:54:00)) and disp(class(13:06:00)) returns double. Not sure why dlmread doesn't work :(
Any help is appreciated. Thanks!
0 Comments
Accepted Answer
Azzi Abdelmalek
on 12 Jun 2013
Edited: Azzi Abdelmalek
on 12 Jun 2013
12:54:00 is double because it represent an empty array starting from 12 to 00 with step=54. type
a=12:54:00
I suggest that you use textscan or fgetl to read your data
fid=fopen('YourFileName.txt')
a=textscan(fid,'%f%f%s%f%f')
fclose(fid)
0 Comments
More Answers (0)
See Also
Categories
Find more on Text Data Preparation 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!