简体   繁体   English

从 Octave 保存 .fig 文件

[英]Saving .fig file from Octave

I need to make a.fig file that can be reopened in Matlab, but I am working in Octave.我需要制作一个可以在Matlab中重新打开的.fig文件,但我在Octave中工作。 But apparently there is no saveas command in Octave.但显然 Octave 中没有saveas命令。 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> 

Currently the Matlab fig file format is a proprietary binary file format. 目前,Matlab图文件格式是专有的二进制文件格式。

Octave doesn't know how to export to this format and won't be able to until it is reverse engineered. Octave不知道如何导出到这种格式,并且在逆向工程之前无法导出。 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. Octave知道的无花果格式是Xfig使用的具有相同扩展名的不同无花果格式,但没有其他共同之处。

To export the plot to other formats in octave use the print command Eg print -deps myplot.eps or print -dpng myplot.png . 要将绘图导出为八度音中的其他格式,请使用print命令例如print -deps myplot.epsprint -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 . 当然,这不会让你在Matlab中打开编辑图,尽管你可以打开使用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. 有一个项目,在读八度位于Matlab的图文件在这里 ,但相关的.m文件似乎并不成功存档。

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. 如果您找到该m文件的副本并且它成功读取Octave中的Matlab图文件,您可以使用它来制作一个Octave脚本,该脚本从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. 或者,您可以使用save命令将矩阵/原始数据加载保存为Matlab .mat文件或其他文件格式,然后将其加载到Matlab中并使用Matlab重新绘制。

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, eg Inkscape.如果您想做的是让其他人能够编辑或注释您的图形,您可以使用print -dsvg myplot.svg将其保存为 SVG 格式,然后可以使用多种工具中的任何一种进行编辑,例如 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.如果您想做的是让其他人将 Matlab 外观应用到您的 plot,您可以使用类似save -mat7-binary 'myvars.mat' 'x' 'y'方法保存您绘制的变量(请参阅: https://www.mathworks.com/matlabcentral/answers/140081-loading-mat-files-in-matlab-created-from-octave ),然后其他人可以使用load 'myvars.mat'和 plot 导入它们在 Matlab 中使用相同的打印选项。

OCTread_FIG(fname,FLAG_PLOT) 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. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%% %% %% [D,items] = OCTread_FIG(fname,FLAG_PLOT) %% %% OCTread_FIG 是一个简单的 function从 %% MATLAB.fig 文件中提取 plot 数据。 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 https://github.com/rohit-gupta/color-categorization-games/blob/master/OCTread_FIG.m

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM