필터 지우기
필터 지우기

dlmread problem could not read file

조회 수: 6 (최근 30일)
strunack
strunack 2012년 12월 19일
I have a text file with tab delimiter. I use
B=dlmread('mon3.txt','',[2 0 20 1]);size (B)
With whatever combination of range, I cannot read the file. If I remove
"Array 1 8192 #startdata" from the first line then I am able to read the file. Its strange. Pls help how to get rid of this problem. Using textscan and fread gives strange values. I want to attach the file mon3.txt itself, but dont know how to do it.
Secondly, I want to mention that I do read variety of files using dlmread and never has any problem.
tks

답변 (1개)

Walter Roberson
Walter Roberson 2012년 12월 19일
dlmread() can only be used for files that are completely numeric, including in the portions of the file that are to be skipped.
Please show a typical line, and please show your attempt to use textscan()
  댓글 수: 1
strunack
strunack 2012년 12월 20일
#'time(sec)' 'mon1' Array 1 8192 T#startdata
0.0 -0.029296875
0.02 -0.029296875
0.04 -0.029296875
0.06 -0.0390625
0.08 -0.048828125
0.1 -0.048828125
0.12 -0.029296875
0.14 -0.029296875
0.16 -0.029296875
0.18 -0.048828125
first few lines of text file looks like this. Now if I remove text
Array 1 8192 #startdata
then I could read using dlmread. Absolutely no problem. So I do not agree with your comment that dlmread cannot read non numeric files. I regularly read files with similar format. But I am stumped to notice this problem with this perticular file. The error is
Error using dlmread (line 139)
Mismatch between file and format string.
Trouble reading number from file (row 1u, field 1u)
==> Array 1 8192 T\n

댓글을 달려면 로그인하십시오.

카테고리

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