Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GUI link to m-file

2,026 views
Skip to first unread message

Nick

unread,
Jul 30, 2009, 10:39:01 AM7/30/09
to
I have created a GUI and corresponding m-file (called SIMPLE.fig and SIMPLE.m respectively) which works fine. I now want to further develop the GUI but not overwrite the existing programme.

So I opened up SIMPLE.fig in guide and saved it as SIMPLE_Online.fig, this automatically created a new m-file called SIMPLE_Online.m.

The problem is, when I now run the SIMPLE_Online GUI it is linked to the original SIMPLE.m m-file even though guide automatically created a new m-file with the correct name.

Am I missing something here? How can I create the link between SIMPLE_Online.fig and SIMPLE_Online.m?

Steven Lord

unread,
Jul 30, 2009, 12:19:24 PM7/30/09
to

"Nick " <nick.c...@avl.com> wrote in message
news:h4sba5$qlv$1...@fred.mathworks.com...

That should have worked, according to the most recent documentation, unless
you're using an older version of MATLAB. I don't remember when GUIDE
started performing the automatic callback updating when you used Save As to
rename your GUI.

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f11-998352.html

If you are using an older version, you may need to search through your
objects for any whose callbacks refer to SIMPLE and modify them to use the
appropriate callback from SIMPLE_Online.

--
Steve Lord
sl...@mathworks.com


Nick

unread,
Aug 4, 2009, 5:19:02 AM8/4/09
to
"Steven Lord" <sl...@mathworks.com> wrote in message <h4sh5t$bg0$1...@fred.mathworks.com>...

>
> That should have worked, according to the most recent documentation, unless
> you're using an older version of MATLAB. I don't remember when GUIDE
> started performing the automatic callback updating when you used Save As to
> rename your GUI.
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/f11-998352.html
>
> If you are using an older version, you may need to search through your
> objects for any whose callbacks refer to SIMPLE and modify them to use the
> appropriate callback from SIMPLE_Online.
>
> --
> Steve Lord
> sl...@mathworks.com
>
Thanks for the reply Steve.

I'm running Matlab R2007b so you're right, that should have worked!
I went through the .m file and all the links were correct so I assumed the problem must be the .fig file. I couldn't find a way of editing any links in guide but I knew a .fig was basically a .mat and I found a rather messy solution:

1. Rename the .fig file as a .mat file
2. Load the .mat file into the workspace, this gives a structure containing all the data the GUI needs. Looking through this, none of the links had been updated.
3. Manually update any field containing "SIMPLE" to "SIMPLE_Online".
4. Save the structure as SIMPLE_Online.mat
5. Rename as SIMPLE_Online.fig (could probably combine these two steps)
6. Close Matlab, reopen and run SIMPLE_Online

All the links now seem to work, but I imagine this is a VERY dodgy way of updating things and it would be very easy to corrupt a file unless you knew exactly what you were doing.

Nick

Brandon

unread,
Sep 23, 2009, 1:55:22 PM9/23/09
to
I am having the same problem, with "save as" not updating the callback functions, and I could fix it by manual correcting the callbacks, as explained above. However, with many call back this is very time consuming. Does anyone know of a fix to have the callbacks updated automatically?

I am using R2007b

Thanks,
Brandon

Y.Farkash

unread,
Sep 24, 2009, 11:14:44 AM9/24/09
to
Same here.

Going through the fig-made-mat file is extremely lengthy (with ~30
callbacks) and as Nick said, very error-prone.

Is there no way to do this automatically? Seems strange that the "save
as" does not update the callbacks.

Cheers,

Yoav

andreas...@gmail.com

unread,
Aug 30, 2013, 6:31:22 AM8/30/13
to
Thank you - you saved my day! It took a long time, but it worked in the end. I also changed the name in the .m file, e.g.
OLDNAME_OpeningFcn(...) -> NEWNAME_OpeningFcn(...)
where I also had to change it another place before it worked:

gui_State = struct(...,'gui_OpeningFcn', @NEWNAME_OpeningFcn,...);
0 new messages