populate a listbox in a GUIDE gui through a function call from a Matlab script (.m file)
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mohammed
el 20 de Nov. de 2017
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 comentarios
Respuesta aceptada
PG_Dev
el 21 de Nov. de 2017
Editada: PG_Dev
el 24 de Nov. de 2017
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 comentarios
PG_Dev
el 22 de Nov. de 2017
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
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!