Reputation: 17316
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>
Upvotes: 7
Views: 9926
Reputation: 1
OCTread_FIG(fname,FLAG_PLOT)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% [D,items] = OCTread_FIG(fname,FLAG_PLOT)
%%
%% OCTread_FIG is a simple function that extracts the plot data from
%% a MATLAB .fig file. It does this by loading the file, which is
%% in struct-format, then parsing down the structure to pull out the data
https://github.com/rohit-gupta/color-categorization-games/blob/master/OCTread_FIG.m
Upvotes: -1
Reputation: 926
If what you want to do is to enable someone else to edit or annotate your figure you could save it in SVG format using print -dsvg myplot.svg
, which could then be edited using any of a number of tools, e.g. Inkscape.
If what you want to do is enable someone else to apply Matlab look and feel to your plot, you could save the variables that you plotted using something like save -mat7-binary 'myvars.mat' 'x' 'y'
(see: https://www.mathworks.com/matlabcentral/answers/140081-loading-mat-files-in-matlab-created-from-octave), then the other person could import them using load 'myvars.mat'
and plot them in Matlab using the same print options.
Upvotes: 1
Reputation: 16116
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.
Upvotes: 8