从 Octave 保存 .fig 文件

发布于 2025-01-05 08:41:44 字数 354 浏览 2 评论 0原文

我需要制作一个可以在 Matlab 中重新打开的 .fig 文件,但我正在 Octave 中工作。但显然没有 saveas 命令在八度。这就是我正在尝试的:

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 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> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

可爱暴击 2025-01-12 08:41:44

目前,Matlab Fig 文件格式是一种专有的二进制文件格式。

Octave 不知道如何导出为这种格式,并且只有经过逆向工程后才能导出。 Octave 所知道的Fig 格式与Xfig 使用的不同Fig 格式具有相同的扩展名,但没有其他共同点。

要将绘图导出为八度音程中的其他格式,请使用打印命令,例如 print -deps myplot.epsprint -dpng myplot.png

当然,这不允许您在 Matlab 中打开绘图进行编辑,但您可以打开使用 imread 生成的图像。

有一个在 Octave 中读取 Matlab Fig 文件的项目位于 这里但是相关的.m文件似乎没有成功归档。

如果您找到该 m 文件的副本,并且它成功读取 Octave 中的 Matlab Fig 文件,您可以使用它来制作一个从 Octave 写入 Fig 文件的 Octave 脚本。

或者,您可以使用 save 命令将矩阵/原始数据加载保存到 Matlab .mat 文件或其他文件格式中,然后将其加载到 Matlab 中并使用 Matlab 重新绘制它。

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.

顾忌 2025-01-12 08:41:44

如果您想要做的是让其他人能够编辑或注释您的图形,您可以使用 print -dsvg myplot.svg 将其保存为 SVG 格式,然后可以使用多种方法之一对其进行编辑工具,例如 Inkscape。

如果您想让其他人将 Matlab 外观应用到您的绘图中,您可以使用 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' 加载它们,并使用相同的打印选项在 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, 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.

帝王念 2025-01-12 08:41:44
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/颜色分类游戏/blob/master/OCTread_FIG.m

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文