Renamed Gui keeps referring to old .m file
2 次查看(过去 30 天)
显示 更早的评论
Hi, I made some some changes to a GUI and renamed it. In the .m file, I changed all occurrences of the old name to the new name. The GUI seems to function fine, but I get a number of errors upon opening the fig file which indicate that something is still trying to open/reference the old GUI or .m file. I get the same errors when filling in character fields when using the GUI. I get these errors:
??? Error using ==> struct2handle
Undefined function or method 'task'
for input arguments of type 'char'.
??? Error using ==> struct2handle
Error while evaluating uicontrol CreateFcn
The old GUI was called 'task.m' and 'task.fig'.
I can't find any references to the old name in the current GUIs .m file; how could it still be referencing the old files? What can I do about this?
Thanks in advance.
Paul
0 个评论
采纳的回答
Walter Roberson
2018-1-25
The .fig that was saved by GUIDE has some anonymous functions stored in it that refer to the old routine names. Because they are stored at the .fig and not in the .m it is not always easy to find them. Once you do find them, you need to change the appropriate property of the .fig to refer to the new name, using the object browser that GUIDE provides.
0 个评论
更多回答(3 个)
Pavel Jelinek
2018-1-16
Hi, just run 'guide' in MATLAB command line and browse&open the renamed GUI. You must not follow 'Recently opened files'.
0 个评论
Image Analyst
2018-1-16
To save a GUIDE-based file with a new name, you must open the .fig file with GUIDE, then do File->SaveAs. It will create a new m-file with the new name and all the places in the m-file should be converted to the new name. But search the new m-file for the old name just in case, and replace any it didn't catch, like where you hard coded the old name into a string, like for example load('oldname.mat') which it wouldn't convert. If you don't need the old named file any more, you can now delete it.
0 个评论
bon sai
2018-1-25
In your m-file.m, please edit in header this line
gui_State = struct('gui_Name', 'new_file.fig', ...
because this line links m-file and fig-file together.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!