Borrar filtros
Borrar filtros

How to assign values to popup menu in GUI?

6 visualizaciones (últimos 30 días)
Quan Seah
Quan Seah el 23 de Abr. de 2018
Respondida: Walter Roberson el 23 de Abr. de 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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de Abr. de 2018

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by