Choosing which value to display

1 view (last 30 days)
I have 5 value, let say A,B,C,D,E. The user got to choose which one(can be more then one),to be display.(I.e, the user choose to look at the value of A,D and E only). What function should i use to display the value accordingly to what the user want. I cannot use if and else function as the option for my value is more then 10. It is going so hard to cover all the possibilities. Please help someone....

Accepted Answer

Walter Roberson
Walter Roberson on 21 Apr 2014
Consider using a button group of toggle buttons http://www.mathworks.com/help/matlab/ref/uibuttongroup.html. When it is time to display items, get() the Children of the uibuttongroup and get() their Value property to determine whether each one is on or off. You can easily build up a logical array of Display / Don't values this way that you can use in a loop or as a logical index as appropriate.
  2 Comments
asedsads asdsaxxz
asedsads asdsaxxz on 21 Apr 2014
Thanks alot for the fast response.Though, i prefer to have a function that doesnt involve any GUI. I have started Matlab just recently, and understanding this function without first understanding GUI is a bit hard. I try to copy all the instruction and paste it in my matlab, and it didnt work. perhaps if its not a nuisance, you can rewrite the function so that it is possible for me to understand more clearly. Thnks again and sory for the problem
Joseph Cheng
Joseph Cheng on 21 Apr 2014
you can use a for loop and a switch/case statement. the for loop will iterate through the number of selections the user selected and the switch/case statement will contain the code for displaying that specific selection.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!