Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving .fig file from Octave

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> 
like image 516
highBandWidth Avatar asked Feb 13 '12 22:02

highBandWidth


People also ask

Can octave Open .fig files?

I recently noticed that octave will load a fig file as a structure, so if you're stuck with trying to open fig files without being able to access Matlab you could try and write an octave function that will load the fig file and reconstitute the plot from the contents of the struct .

How to save a fig MATLAB?

To save the current figure, specify fig as gcf . saveas( fig , filename , formattype ) creates the file using the specified file format, formattype .

How to save MATLAB figure as vector graphic?

You can save plots as images or as vector graphics files using either the export button in the axes toolbar, or by calling the exportgraphics function.


1 Answers

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.

like image 73
Appleman1234 Avatar answered Sep 19 '22 22:09

Appleman1234