Saving .fig file from Octave

highBandWidth picture highBandWidth · Feb 13, 2012 · Viewed 8.2k times · Source

I need to make a .fig file that can be reopened in Matlab, but I am working in Octave. But apparently there is no saveas command in Octave. This is what I am trying:

octave:3> plot([1,2,3],[45,23,10])
octave:4> saveas(gcf,'myfig.fig')
error: `saveas' undefined near line 4 column 1
octave:4> 

Answer

Appleman1234 picture Appleman1234 · Feb 14, 2012

Currently the Matlab fig file format is a proprietary binary file format.

Octave doesn't know how to export to this format and won't be able to until it is reverse engineered. The fig format that Octave knows about is a different fig format used by Xfig with the same extension name, but nothing else in common.

To export the plot to other formats in octave use the print command E.g print -deps myplot.eps or print -dpng myplot.png .

Of course this doesn't let you open the plot for editing in Matlab , though you can open the image generated using imread.

There was a project to read Matlab fig files in Octave located here but the relevant .m file doesn't seem to be archived successfully.

If you found a copy of that m file and it successfully read Matlab fig files in Octave you could use it to make an Octave script that wrote fig files from Octave.

Alternatvely you can use the save command to save the matrix / raw data load into a Matlab .mat file or other file format, then load that in Matlab and replot it with Matlab.