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>
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 .
To save the current figure, specify fig as gcf . saveas( fig , filename , formattype ) creates the file using the specified file format, formattype .
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With