How to adapt matlab with a new file format?

1 次查看(过去 30 天)
Hi all,
If I need to add a new file extension such as *.abcd which is not supported by matlab, where I have to start?
Many thanks

回答(3 个)

Orion
Orion 2014-10-17
Hi,
What do you want to write in this file ? Text, formatted binary file ,...
for a text, you can do the usual operation using fopen, fprintf, fclose.
fid = fopen('TestFile.abcd','wt');
fprintf(fid,'Hello World\n');
fclose(fid);
and then to read this file, just use textread
Text = textread('TestFile.abcd','%s','delimiter','\n')
  1 个评论
JMS
JMS 2014-10-17
Hi Orion,
No it is kind of images which is not supported by matlab. If I want to open it in matlab, it needs to be saved as *.tif format and then I can open it.
Many thanks.

请先登录,再进行评论。


Orion
Orion 2014-10-17
I'm no expert in image processing, but can't you just use imread ?
if you're really stuck, you should add an example attached to your question, because it's hard to guess what can happen with your special extension, or contact Mathworks.

John D'Errico
John D'Errico 2014-10-17
If this is a file type that is NOT supported by MATLAB for reading, then nothing you do will make imread (or whatever file read tool you want) read it. Code needs to know what to expect. No magic exists.
Having said that, there is no reason why you cannot read in this file, however you will need to write code that knows how to read the file. MATLAB can see the file in your directories, regardless of what the extension is. So you will need to write a tool that understands what the file is. Are there headers? If so, then read them in, in the appropriate format, since YOU know what to expect. You might be using tools like fopen, fclose, fgets, fgetl, or perhaps textread.

类别

Help CenterFile Exchange 中查找有关 Low-Level File I/O 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by