Plotting histograms using callbacks and dropdown/pop-up menus

3 visualizzazioni (ultimi 30 giorni)
I'm attempting to create a figure which contains a drop down menu. Very similar to the example provided here on MatWorks. I want to copy the "drop-down" list so that depending on which value is chosen, a different group of data is plotted. Example data and code are attached
Below is an example I've photoshopped to demonstrate what I'm trying to do. I've read about using Callbacks but have had limited success. Below is the view I would like when "Graph1" is selected from the dropdown and "Count" is the button pressed.
when "Graph1" is selected from the dropdown and "Percentage" is the button pressed.
So based on what the user selects the data in my function will change. Here's an example of a table containing some of the data. One issue is that both grpstats and splitapply don't count instances of 0 (as you'll see below I manually add them back in before graphing).
Any help on getting these callbacks working so I have a drop-down menu would be awesome. If my questions aren't clear please let me know. I'll make further clarifications as needed.

Risposte (1)

Image Analyst
Image Analyst il 2 Feb 2018
Assuming the buttons call some custom written function, just have the callback of the popup call that function.
selectedIndex = handles.popup1.Value
if selectedIndex == 1
function1(arguments); % Call function1()
elseif selectedIndex == 2
function2(arguements) % Call function2()
end
  2 Commenti
Patrick
Patrick il 2 Feb 2018
Thank you for your answer.
The issue I'm having is that the data I want to use is dependent on values given to me by both the dropdown and a button press. It would be similar to if "current_data" in this example was dependent on both values given by BOTH which button is pressed and which value is given in the dropdown menu.
Image Analyst
Image Analyst il 2 Feb 2018
Not sure I follow because it's kind of vague. But you can take whatever information you have from the drop down list, and the buttons, and pass that information into function1() or function2() via the argument list. If there are "global" variables that you set in the button callback first that need to be available in either the dropdown callback function or the two other functions, then there are ways to get those variables into those functions. These ways are described in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F

Accedi per commentare.

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by