Why dlmread do not work with dlmwrite?
이전 댓글 표시
hi, I wrote symbols to file using dlmwrite, where the file became:
?,R,M,G,f,D,[],[]
W,E,R,R,T,U,H,K
N,D,F,[],[],[]
when tried to read it with dlmread , I got :
??? Error using ==> dlmread at 145
Mismatch between file and format string.
Trouble reading number from file (row 1, field 1) ==> ?,R,K
thanks
댓글 수: 4
Jan
2011년 12월 10일
Please post the code you have been using for writing and reading.
huda nawaf
2011년 12월 10일
huda nawaf
2011년 12월 10일
Walter Roberson
2011년 12월 10일
As already explained, but I have expanded my answer to discuss this pointer further.
답변 (1개)
Walter Roberson
2011년 12월 10일
dlmread() can only read numeric data.
You have to cheat with dlmwrite() in order to write character data with it: it is not designed to write characters.
I did firmly say that I do not recommend that you use dlmwrite() to write character data, and that I only came up with the method to be contrary when someone said that it could not be done. I think I showed the code for the fopen / fprintf / fclose alternative.
[added]
When I said that dlmread can only read numeric data, I meant exactly that. It states this clearly in the documentation:
Tips
All data in the input file must be numeric. dlmread does not read files that contain nonnumeric data, even if the specified rows and columns contain only numeric data.
I have also examined the code that it uses; it uses an undocumented facility, but there is no doubt through testing that the facility will ONLY read numeric data.
카테고리
도움말 센터 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!