populate a listbox in a GUIDE gui through a function call from a Matlab script (.m file)
4 次查看(过去 30 天)
显示 更早的评论
While Im quite comfortable with functions and scripts in matlab, this is my first time venturing into GUIDE guis. I created a figure containing a listbox, a drop down list as well as a plot. The idea is to call this gui from a Matlab script under certain conditions, populating the listbox with a list of files. The user would select a plot "profile" from the drop down list which will then select the appropriate plots to show.
At this point Im struggling with just getting the listbox to update properly. I saved my gui generated from GUIDE as svt_plotter, which I call from my script with:
H= svt_plotter({'A','B'});
In the svt_plotter.m file I added the following line in svt_plotter_OpeningFcn just before the call to update handles structure: handles.list = varargin{1}; %save the input argument to be used in the listbox function later. This is a straight call right now with no logic to see if it works
finally I added this line to update the listbox under listbox1_CreateFcn set(hObject, 'String', handles.list);
When I do this I get an error 'Attempt to reference field of non-structure array.'. Replacing the handles.list with the explicit cell array works just fine. What am I missing here?
Any good reference document that can help in understanding GuIDE code and how to interact with it would be much appreciated.
0 个评论
采纳的回答
PG_Dev
2017-11-21
编辑:PG_Dev
2017-11-24
Mohammed,
Remove handles.list = varargin{1} and put this line in svt_plotter_OpeningFcn
set(handles.listbox1, 'String', varargin{1});
Remove set(hObject, 'String', handles.list) from the listbox opening function. Its throwing that error because 'handles' is an empty array in the listbox opening function argument and not the 'handles' from the svt _plotter opening function.
Best Regards
PG
3 个评论
PG_Dev
2017-11-22
Mohammed,
As I've mentioned in my answer before please put the statement in the svt_plotter_OpeningFcn and not in the listbox1_CreateFcn. It will work. From your error message Error in svt_plotter>listbox1_CreateFcn (line 191) it appears that you put the statement in the listbox1_CreateFcn.
-PG
更多回答(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!