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 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