Reading a .dat file with textread
조회 수: 2 (최근 30일)
이전 댓글 표시
How do you read .dat file that contains 5 .jpg images in it using textread?
Also, how do you output the filenames?
댓글 수: 0
채택된 답변
Walter Roberson
2012년 6월 22일
jpg images are binary images, but textread() is for reading text files.
Does the .dat file perhaps contain the names of the images rather than the images themselves?
There is no standard format for .dat files: it is a suffix used by any program to hold any data. You need to know the internal structure of that particular .dat file in order to work with it. It might be pure text (most .dat files are not).
If you can upload a sample of the file, someone might have a look at it. http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
댓글 수: 9
Walter Roberson
2012년 6월 23일
I'm not sure what you mean, but anyhow...
fid = fopen('TheFileName.txt','wt');
fprintf(fid, '%s\n', filename{:});
fclose(fid)
I am assuming here that filename is a cell array of strings. If it is a plain string then you may have to break it apart if you want one filename per line. Or perhaps just
fid = fopen('TheFileName.txt','wt');
fprintf(fid, '%s\n', filename);
fclose(fid)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!