Gui cannot find the listbox1 when I run the fig file

1 view (last 30 days)
Dear all,
Silently, I have followed this help center for 2 years. I thank you all for you to teach me matlab from scratch. Recently, I started to work on gui matlab and I learned a lot as a beginner to gui. I couldn't figure out a problem and couldn't find an answer here.
I created a gui code. When I run it from gui editor by using the run figure (Ctrl + T) it works, but when I open the fig file by double clicking it doesn't work. The reason is the listbox cannot be recognized (Attempt to reference field of non-structure array). Here is the code for Find .xls Files button and a picture of gui design. Basically, I search the folder for certain xls files and sort them in order than load them into the matlab and make some calculations and plot normalized values and regular values. Again, The gui works when I open it from the gui editor but doesn't want to run when I click the button. I hope I was clear on describing my problem.
Thank you all,
files = dir(fullfile(pwd,'*_03_graphfiles.xls'));
set(handles.listbox1,'Max',2,'Min',0,'string',{files.name});
files = dir(fullfile(pwd,'*_04_graphfiles.xls'));
set(handles.listbox3,'Max',2,'Min',0,'string',{files.name});
files = dir(fullfile(pwd,'*_05_graphfiles.xls'));
set(handles.listbox4,'Max',2,'Min',0,'string',{files.name});
set(handles.listbox1, 'Value', []);
set(handles.listbox3, 'Value', []);
set(handles.listbox4, 'Value', []);
set(handles.listbox5, 'Value', []);

Accepted Answer

Geoff Hayes
Geoff Hayes on 3 Aug 2015
Ahmet - double-clicking on the figure file will not launch the GUI in a way that you can use it. All that you will observe, is the figure with its controls. Opening the GUI in this way skips certain variable initializations that would normally occur when you launch the GUI correctly.
A GUI can only be launched through GUIDE, by pressing the run button while viewing/editing the GUI m file in the editor, or by calling your GUI by name from the command line as
>> myGui
  1 Comment
Ahmet
Ahmet on 4 Aug 2015
Thank you. I learned it :). I thought I created a package with gui. However, I can create an app in matlab which works for now.
Thanks again,

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!