Number of button groups in GUI depending on user input?

Let's say I have a structure of data loaded in my the user. The size of this structure depends on the number of measurements taken. I want to create a GUI that asks the user to choose which type of processing they want to apply for each measurement. Therefore, I want a different number of button groups to be created based on the number of measurements contained in the structure. How would I go about doing this?
I am new to GUI coding and haven't been able to find a complete tutorial for what I want to achieve. I am hoping someone can guide me, or point me in the direction of some easy-to-follow resources! :)

3 Comments

You can put uibuttongroup() and/or uicontrol() in a loop to create N number of buttons. Something like below.
N = input();
h = figure;
for i = 1:N
b{i} = uibuttongroup(h,'Position',[10,22*i,100,20],'units','pixels');
% uicontrol(b{i},'Position',...)
end
For general advice and examples for how to create a GUI (and avoid using GUIDE), have look at this thread.
Great help guys! Thank you so much!

Sign in to comment.

Answers (1)

I would question the premise...
How about having a listbox that lists each measurement, and only a single button group, whose contents change depending on which measurement is selected (in the listbox)?

4 Comments

I see what you mean! It is a great idea, but for my specific case, I would worry about the user losing their overview of exactly what happens to every measurement. In addition, the contents of the button group would remain the same for each measurement, and only the user's choice of processing might change depending on the measurement in question. For 10 measurements, having a listbox would mean the user would need to select each measurement in the listbox and then choose the appropriate processing for each of them (20 to 30 clicks), which is a lot more clicks than having a button group for each of the measurements (10 clicks).
I understand, and "number of clicks" is a great way to assess the UI!
So you'd just have 1 to kick off each processing option? How many different processing options are there? For example, if there are only 2 or 3 options, I think the strategy might be different than if you had 10 different options.
For the specific problem I'm dealing with, "processing" is not really the right word, but I used it to create an analogy that might be easier to explain quickly!
In fact, for each measurement (which is actually a complete dataset measured with different settings), the user should have three options: manually choose to delete outliers, load a file of previously chosen outliers to delete (if this exists), or delete no points. For the first two options, once the chosen/loaded datapoints have been deleted, the user will then need to check the data again and decide whether to choose additional outliers to delete until they are happy with the data.
The project is currently coded in such a poor way that the user is spammed with figures and dialogue boxes to choose/load points for every single dataset. In some cases, the code is broken or hardcoded such that choosing the wrong option at the wrong time will crash everything!
I decided to take it as an opportunity to learn more about GUI and make it a bit more user-friendly, something my supervisor has complained about not having the time to do. If you have any ideas for how to do this in an efficient way, I'm all ears! But honestly, even the simplest GUI is an improvement at this point!
Thanks for taking an interest :)
But how will the user decide which option to choose? Will they first need to be presented with a single visualization of all the data? Does it make sense to forget about the fact that there are multiple data sets in the data structure, and think about the workflow per each data set?

Sign in to comment.

Categories

Find more on App Building in Help Center and File Exchange

Products

Release

R2020b

Asked:

on 1 Dec 2020

Commented:

on 1 Dec 2020

Community Treasure Hunt

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

Start Hunting!