Errors launching GUI built in GUIDE

2 visualizzazioni (ultimi 30 giorni)
Daniel
Daniel il 18 Lug 2011
Commentato: Nir Kaplan il 1 Ago 2019
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.

Risposte (4)

Daniel Higginbottom
Daniel Higginbottom il 28 Feb 2012
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 Commento
Nir Kaplan
Nir Kaplan il 1 Ago 2019
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')

Accedi per commentare.


Friedrich
Friedrich il 21 Dic 2011
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 il 18 Lug 2011
  • 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 il 21 Dic 2011
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.

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by