필터 지우기
필터 지우기

dlmread not working as expected...

조회 수: 3 (최근 30일)
Benson
Benson 2013년 6월 12일
%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!

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 6월 12일
편집: Azzi Abdelmalek 2013년 6월 12일
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개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by