Reading a .dat file with textread

6 次查看(过去 30 天)
How do you read .dat file that contains 5 .jpg images in it using textread?
Also, how do you output the filenames?

采纳的回答

Walter Roberson
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).
  9 个评论
Walter Roberson
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)
Jonathan
Jonathan 2012-7-5
Thanks a lot! I just needed to add the t next to the w in 'wt' in fid = fopen('TheFileName.txt','wt');. It works perfectly now.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by