Errors launching GUI built in GUIDE

2 次查看(过去 30 天)
Daniel
Daniel 2011-7-18
I have a GUI that I have been working on for some time.
It was running perfectly well until I made some small changes to the figure in GUIDE.
Now when I attempt to start the GUI I get the following errors:
??? Error using ==> struct2handle Values must be finite and non-NaN
Error in ==> hgloadStructDbl at 97 h = struct2handle(hgS, parent, flags{:});
Error in ==> hgload at 69 [h, OldProps] = hgloadStructDbl(FigData, fullpath, VerNum, LoadAll, OverrideProps);
Error in ==> openfig at 72 [fig, savedvisible] = hgload(filename, struct('Visible','off'));
Error in ==> gui_mainfcn>local_openfig at 286 gui_hFigure = openfig(name, singleton, visible);
Error in ==> gui_mainfcn at 159 gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
Error in ==> Console at 43 gui_mainfcn(gui_State, varargin{:});
I also get similar errors when I try to open the figure file in GUIDE.
The problem developed after I added two push buttons to the GUI.
Any help will be greatly appreciated because this problem has me completely stumped.

回答(4 个)

Daniel Higginbottom
I did eventually resolve this error and discover its cause.
While editing the GUI in Guide I shrunk a uipanel containing controls so that I could focus on other aspects of the figure. At this size the controls on the GUI were given NaN property values for height, width and also fontsize. It is easy to correct this while in Guide, but if you make the mistake of saving the figure and closing Guide then the figure is corrupted and can't be run or opened for editing.
In order to resolve the problem I stopped at the error on line 97 in hgloadStructDbl and inspected the structure hgS. This contains property values for all the items in the GUI. I found the NaN values by digging around (which took quite some time, it's a complicated figure!) and added some lines of code which replaced these with finite values.
eg. hgS.children(1).children(1).children(4).properties.Position = [0.1, 0.1, 0.1, 0.1]
I could then open the figure in Guide, fix the positions, and save a new version. After which I returned hgloadStructDbl to normal.
  1 个评论
Nir Kaplan
Nir Kaplan 2019-8-1
worked for me!
In "hgloadStructDbl" I added a breakpoint on the line:
h = struct2handle(hgS, parent, flags{:});
I used "assignin" to save the struct and flag:
assignin('base','GuiStruct',hgS)
assignin('base','flags',flags)
saved the struct and flag from the workspace as an .mat file.
Than i created a figure and run over the childrens in "GuiStruct", antill i found the corrupted children.
struct2handle(GuiStruct.children(1), Fig)
struct2handle(GuiStruct.children(2), Fig)
. . .
struct2handle(GuiStruct.children(7), Fig)
The seventh child throw a error.
So i cleared it from the structure, recreate the GUI, save it and open it in Guide.
GuiStruct.children(7) = [];
fig = struct2handle(GuiStruct, 0, 'convert');
set(fig,'Visible', 'on')
savefig(fig, 'GUIRestore')

请先登录,再进行评论。


Friedrich
Friedrich 2011-12-21
Hi,
I can remember this error somehow. I think it was due some uicontrols and their properties in R2009a. Try to make sure that all your uicontrol objects have finite and non-NaN positions before saving.
You could use the Object browser to identify objects not fully displayed or located behind a panel within the .fig file.

Sean de Wolski
Sean de Wolski 2011-7-18
  • What small changes?
  • Did you delete something that had a create/callback function?
  • How are you calling the function?
  • Did you move/rename/delete etc. the *.fig file?

Matthew Arthington
Matthew Arthington 2011-12-21
I also get an error with hgloadStructDbl at line 97. I get the error if I step over my command inside debug mode (Matlab then stops, because I have always stop at errors enabled, at line 97 in hgloadStructDbl, but it won't tell me what's wrong, or even let me know that I've entered a new function). This is my command:
[s,r]=system('"Plots\BodePlot.fig"');
if I don't run it inside debug mode, then I get the message: "Error Writing Pipe." on the command line, but nothing more from Matlab. The command just fails to execute correctly but Matlab carries on running. I'm running Windows 7 Matlab 2010b.
Changing my command to
open('Plots\BodePlot.fig')
has substituted the functionality I wanted, but it doesn't solve the above issue.

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by