Gui cannot find the listbox1 when I run the fig file
1 次查看(过去 30 天)
显示 更早的评论
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', []);
0 个评论
采纳的回答
Geoff Hayes
2015-8-3
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
更多回答(0 个)
另请参阅
类别
在 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!