フィルターのクリア

How to assign values to popup menu in GUI?

4 ビュー (過去 30 日間)
Quan Seah
Quan Seah 2018 年 4 月 23 日
回答済み: Walter Roberson 2018 年 4 月 23 日
I have a GUI to calculate the resistance of a resistor based on the number of bands and the color orders. I have 10 different colours, such as black, brown, red etc. I had tried to assign values to each color by using the following codes:
contents = cellstr(get(hObject,'string'));
popChoice = contents(get(hObject,'value'));
if strcmp(popChoice,'Black')
popVal = 0;
elseif strcmp(popChoice,'Brown')
popVal = 10;
elseif strcmp(popChoice,'Red')
popVal = 20;
elseif strcmp(popChoice,'Orange')
popVal = 30;
elseif strcmp(popChoice,'Yellow')
popVal = 40;
elseif strcmp(popChoice,'Green')
popVal = 50;
elseif strcmp(popChoice,'Blue')
popVal = 60;
elseif strcmp(popChoice,'Violet')
popVal = 70;
elseif strcmp(popChoice,'Grey')
popVal = 80;
elseif strcmp(popChoice,'White')
popVal = 90;
end
assignin('base','SecondColor',popVal)
The codes I used above actually works but all it does is saved the value into workspace and I have no idea how to use the value that's saved in the workspace to do calculation. Additionally, I had another function file that will do all the calculation based on the information gathered but I also have no clue on how to actually use it in GUI.Please help.

採用された回答

Walter Roberson
Walter Roberson 2018 年 4 月 23 日

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by