Filter löschen
Filter löschen

How to assign values to popup menu in GUI?

6 Ansichten (letzte 30 Tage)
Quan Seah
Quan Seah am 23 Apr. 2018
Beantwortet: Walter Roberson am 23 Apr. 2018
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 23 Apr. 2018

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by