Why can't I launch my GUI with a listbox directly by opening the .fig file?

2 views (last 30 days)
As soon as I close the Layout Editor and the .fig file of a GUI, and attempt to start the GUI directly by opening the .fig file, the listbox no longer displays its items and I get the error message
Attempt to reference field of non-structure array 'handles'

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 10 Sep 2012
The proper way to launch a GUI (other than 'activate figure' from the Layout Editor) is to call the application program file. For example, if you created a GUI named 'test' with GUIDE, you will generally have two files: test.fig and test.m. To launch this GUI execute:
test
from the MATLAB Command Prompt.
In your test.m file you have the following line:
fig = openfig(mfilename,'reuse');
which opens the figure file (in this case: test.fig).
If you try to launch the GUI by opening the test.fig file directly, MATLAB has no reference to the test.m file, where you have, for example, your callbacks. This file also is used to create a structure called 'handles', which is then used to store the handles to all the uicontrols in your GUI.

More Answers (0)

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!