How to adapt matlab with a new file format?

1 Ansicht (letzte 30 Tage)
JMS
JMS am 17 Okt. 2014
Beantwortet: John D'Errico am 17 Okt. 2014
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

Antworten (3)

Orion
Orion am 17 Okt. 2014
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 Kommentar
JMS
JMS am 17 Okt. 2014
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.

Melden Sie sich an, um zu kommentieren.


Orion
Orion am 17 Okt. 2014
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 am 17 Okt. 2014
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.

Kategorien

Mehr zu Low-Level File I/O finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by