How do you fill a GUIDE generated listbox with strings from a multileveled struct?

7 views (last 30 days)
I am trying to create a GUI to assist in the visualization/analysis of data for a large research study. In particular, the study consists of approximately 45 test subjects, each of which will have 4 test sessions. These sessions will consist of 4 test segments that all record data from 6 data channels. I wrote a function that automatically imports all of the data and stores it into a multileveled struct that is something like this:
subject.sessions.segment.dataChannel
In addition, subject IDs are stored in:
subject.name
I would like to be able to first autopopulate a GUIDE generated listbox with the string names from struct.name (with the ability to select multiple), then populate a second listbox with available sessions, and a third with available segments. The dataChannels I would like to select from a drop down menu and then have the GUI trace back to the appropriate data in the struct for the specific subject(s)/session/segment combination, and then plot/display the data.
I am very new at GUIDE and have never made a GUI before, so I am having a very difficult time figuring out how to write the callbacks appropriately. Any help I could get would be much appreciated. Thanks in advance!

Accepted Answer

Joseph Cheng
Joseph Cheng on 8 Sep 2014
Edited: Joseph Cheng on 8 Sep 2014
Well first you'll have to figure out how to work in cells. Since i do not know how you've got your subject.name constructed subject(N).name where N is subject ID or subject.Name(N). lets go with subject(N).name. With that you'll have to build a cell array to populate the first listbox.
for ind=1:length(subject)
LboxNames{ind} = subject(ind).name; %compile cell array of names.
end
set(handles.listbox1,'string',LboxNames);
set(handles.listbox1,'max',length(LboxNames)); %make it so you can select more than 1.
to populate the next two list boxes you should check the value of what was selected in listbox 1. to do this you can use the
get(handles.listbox1,'value')
which will give you the index # of what was selected. from there i'm sure you can figure out how to create and display the next two list boxes based on the above example.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps 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!