如何更改 MATLAB GUIDE 图回调文件名?

发布于 2024-12-04 16:21:28 字数 647 浏览 2 评论 0原文

MATLAB GUIDE 是在 MATLAB 中进行 GUI 编程的实用程序。

如果设计一个名为 myfigure 的图窗,它会创建两个文件 myfigure.fig(其中包含 GUI 布局描述)和 myfigure.m(其中包含回调)描述 GUI 背后的逻辑(例如,当您单击按钮时,将调用某个函数,并且 .m 文件旨在包含此类回调函数的代码)。

如何将 myfigure.m 的名称更改为 myfigure_callbacks.m 并且仍将 myfigure_callbacks.m 中的函数与 GUI 中描述的绑定myfigure.fig

所以我想要名为

myfigure.figmyfigure_callbacks.m

的文件,而不是

myfigure.figmyfigure.m >

MATLAB GUIDE is a utility for GUI programming in MATLAB.

If designing a figure named myfigure it creates two files myfigure.fig, which contains the GUI layout description, and myfigure.m which contains the callbacks describing the logic behind the GUI (e.g. when you click a button, a certain function is being called, and the .m file is intended to contain codes of such callback functions).

How can I change the name of myfigure.m to myfigure_callbacks.m and still have the functions in myfigure_callbacks.m bound with the GUI described at myfigure.fig?

So I want to have files named

myfigure.fig and myfigure_callbacks.m

instead of

myfigure.fig and myfigure.m

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

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

发布评论

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

评论(1

情丝乱 2024-12-11 16:21:28

根据文档,这是无法完成的。

定义 GUI 的代码文件和 Fig 文件必须具有相同的内容
姓名。该名称也是您的 GUI 的名称。

以下是 Mathworks 的文档:命名 GUI 及其文件


编辑:
正如您所观察到的,重命名 GUI 的目的是重命名关联的Fig 和代码文件(自动)。

要重命名 GUI,请使用布局中的“另存为”重命名 GUI 图文件
编辑器文件菜单。当您执行此操作时,GUIDE 会重命名两个Fig 文件
和 GUI 代码文件,更新包含以下内容的任何回调属性
旧名称以使用新名称,并更新该名称的所有实例
代码正文中的文件名。

According to the documentation this cannot be done.

The code file and the FIG-file that define your GUI must have the same
name. This name is also the name of your GUI.

Here's the documentation from Mathworks: Name a GUI and Its Files.


Edit:
As you observed, renaming the GUI is intended to rename associated FIG and code files (automatically).

To rename a GUI, rename the GUI FIG-file using Save As from the Layout
Editor File menu. When you do this, GUIDE renames both the FIG-file
and the GUI code file, updates any callback properties that contain
the old name to use the new name, and updates all instances of the
file name in the body of the code.

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