How can I use a GUI listbox to select and concatenate coordinates for a line graph?

1 view (last 30 days)
I am creating a GUIDE GUI to help visualize/analyze a large amount of data for a study. Once data is imported, the struct looks something like this:
handles.subject.session.segment.signal
There are upwards of 50 subjects, each with 4 sessions. Each session consists of 4 segments, and each segment collects data for several different signals, such as temperature, heart rate, time, etc.
I would like to be able to allow a GUI user to select and plot multiple segments on the same graph. I know that concatenating coordinates is possible with:
plot(x1,y1,x2,y2,...,xn,yn)
More specifically, if I want to plot temperature in segments 1 and 3 for a particular subject, I would expect the code to be something like:
handles.xcoord1 = handles.subject(1).session(1).segment(1).time_sec
handles.xcoord3 = handles.subject(1).session(1).segment(3).time_sec
handles.ycoord1 = handles.subject(1).session(1).segment(1).temp
handles.ycoord3 = handles.subject(1).session(1).segment(3).temp
plot(handles.xcoord1, handles.ycoord1, handles.xcoord3, handles.ycoord3)
Or if I wanted heart rate for segments 2, 3, and 4, it would look something like this:
handles.xcoord2 = handles.subject(1).session(1).segment(2).time_sec
handles.xcoord3 = handles.subject(1).session(1).segment(3).time_sec
handles.xcoord4 = handles.subject(1).session(1).segment(4).time_sec
handles.ycoord2 = handles.subject(1).session(1).segment(2).HR
handles.ycoord3 = handles.subject(1).session(1).segment(3).HR
handles.ycoord4 = handles.subject(1).session(1).segment(4).HR
plot(handles.xcoord2, handles.ycoord2, handles.xcoord3, handles.ycoord3, handles.xcoord4, handles.ycoord4)
With several different subjects, sessions, segments, and signals it's clear that writing out every possible iteration of this would be exhausting. I feel like there must be a better way. How can I write code such that MATLAB will automatically generate the appropriate coordinates to concatenate and plot based on the segments chosen by the user?
Please let me know if anything here is not clear enough or if I need to provide additional information. Thank you for your help!

Answers (0)

Community Treasure Hunt

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

Start Hunting!