1)I have a menu with 4 options. I need to make another menu that has all the options from the previous menu except the option that was previously selected. What do I do?
2)My code uses the option number outputed from the menu to extract a value from a matrix. On the second menu, one option will be removed so the outputted number will not extract the correct matrix values anymore. Is there anyway I can keep the same values on the second menu as the first menu after one option is removed?
EX) If someone selects option 2 from the first menu my code is set up to put the value into value=matrixname(option#selected, columnnumber)
if one option is removed it will not extract the correct value anymore. What should I do?

답변 (1개)

Adam Danz
Adam Danz 2019년 9월 8일
편집: Adam Danz 2019년 9월 9일

0 개 추천

"Is there anyway I can keep the same values on the second menu as the first menu after one option is removed?"
Instead of using the option number from the menu, match the selection to an independent list that won't change.
allPossibleOptions = {'white','green','red','blue'};
selection = 'red';
value = find(strcmp(allPossibleOptions,selection));

댓글 수: 1

Adam Danz
Adam Danz 2019년 9월 8일
편집: Adam Danz 2019년 9월 10일
If you're using app designer, an alternative to my answer above is using the ItemsData property to store a value that is independent of the order of options in the menu. When you make a selection, the ItemsData value is returned and can be used as an index.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

태그

질문:

2019년 9월 8일

편집:

2019년 9월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by