3

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

Jonas Heidelberg
  • 4,984
  • 1
  • 27
  • 41
Vahagn
  • 4,670
  • 9
  • 43
  • 72
  • Why exactly do you need this? Would a file system hardlink `myfigure_callbacks.m` -> `myfigure.m` be a solution for you? – Jonas Heidelberg Sep 16 '11 at 14:53
  • Note that (a) you don't need to have your callbacks in the `.m`-file; you can write a file for each callback individually (or write a class etc), and that (b) the `.m`-file is how you call the GUI, i.e. instead of calling `myGUI`, you'd call `myGUI_callbacks`, which may confuse you in a few months. – Jonas Sep 16 '11 at 17:11
  • @Vahagn: Another possibility is to export you GUI as a self-contained single M-file from GUIDE: http://stackoverflow.com/questions/6548189/relocating-fig-files-when-creating-a-gui-using-matlab-guide/6556947#6556947 – Amro Sep 17 '11 at 12:51

1 Answers1

2

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.

gary
  • 4,227
  • 3
  • 31
  • 58