Copying a matlab gui to a different directory

2 views (last 30 days)
Tomithicus
Tomithicus on 9 Sep 2019
Edited: Adam Danz on 13 Sep 2019
Hello,
I'm having a whole host of errors stemming from a simple (in my mind) problem.
I have a complicated GUI that I wrote. I want to modify it to import a different type of data, but do this in a copy of the GUI in a different directory.
I have tried:
1) Copying both the .fig and .m file and renaming all "GUI_V1" to "GUI_V2" in the .m file... Doesn't work.
2) Opening GUI_V1 within GUIDE, save as -> GUI_V2... Doesn't work and I get a slew of different errors. It sometimes generates a new .m file with the appropriate title but the .fig file doesn't save.
Has anyone gotten past this? Thanks!
  3 Comments
Tomithicus
Tomithicus on 9 Sep 2019
Edited: Tomithicus on 9 Sep 2019
@Adam Danz, I get this even when I try to make updates to the original .fig file. Very frustrating. I agree that encorporating the extra functionality in the first gui is a good idea, but it seems like thats even complicated now.
Adam Danz
Adam Danz on 10 Sep 2019
I listed some troubleshooting steps below. After you're done the renaming, if you still have a problem please attach the m file and fig file.

Sign in to comment.

Answers (1)

Adam Danz
Adam Danz on 9 Sep 2019
Edited: Adam Danz on 13 Sep 2019
This is among the common problems with GUIs produced in GUIDE. Many volunteers in this forum are not shy about their disdain for GUIDE GUIs. Custom made GUIs created with uicontrol() are much better.
How to correctly rename a GUIDE GUI
To rename a GUIDE gui you have to open the GUI in GUIDE, go to file > saveas, and enter a new filename. That creates a new fig and m file under the new GUI name. Manually changing the m file name and figure name is not enough and will break the GUI as you are experiencing.
Fixing your improperly renamed GUIDE GUI
Fixing this may not be easy. Start by backing up a copy of what you've got because your efforts to fix it may corrupt it further.
Then rename the original m file and figure to their original names (case sensitive). Then open the mfile and search for any instances of the 'wrong' GUI name and change it back to the original GUI name. The GUI name may appear in the following areas, and in additional places unique to your GUI.
  • In the first line at the main function name
  • toward the top of the m file where gui_State structure is formed. You'll see function handles with the GUI name
  • In the OpeningFcn function
  • In the OutputFcn function
  • Potentially other areas unique to your GUI
Then try to open the GUI in GUIDE.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!