How to adapt matlab with a new file format?

1 回表示 (過去 30 日間)
JMS
JMS 2014 年 10 月 17 日
回答済み: John D'Errico 2014 年 10 月 17 日
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 Center および File ExchangeLow-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