How work with 2 popup menus
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Jhon Rackham
el 1 de Sept. de 2019
Comentada: Jhon Rackham
el 2 de Sept. de 2019
Hi to everyone !
I need your help guys, i'am a beeginer in Matlab and i have a problem with my project:
Well, i have to create a program that converts whatever number set to the measures: (Kilometers, meters, centimeters and millimeters).
On mi GUI i have 2 edit text and 2 popupmenu
The idea is:
I put one numer on the edittext1 and i choose in the popupmenu1 what measure it is(Kilometers, meters, centimeters and millimeters).
Then, on the other popupmenu i choose what measure in want to convert and that value has to print on the edittext 2. is like google conversor.
I don't know how to work with 2 popupmenus, i hope you guys help me.
Have a good day. :D
0 comentarios
Respuesta aceptada
Image Analyst
el 2 de Sept. de 2019
Editada: Image Analyst
el 2 de Sept. de 2019
Try something like this
value = str2double(handles.edittext1.String)
if handles.popupmenu1.Value == 1
if handles.popupmenu2.Value == 1
convertedValue = value * 123.4567; % Or whatever it is.
elseif handles.popupmenu2.Value == 2
elseif handles.popupmenu2.Value == 3
elseif handles.popupmenu2.Value == 4
elseif handles.popupmenu2.Value == 5
end
elseif handles.popupmenu1.Value == 2
if handles.popupmenu2.Value == 1
elseif handles.popupmenu2.Value == 2
elseif handles.popupmenu2.Value == 3
elseif handles.popupmenu2.Value == 4
elseif handles.popupmenu2.Value == 5
end
elseif handles.popupmenu1.Value == 3
if handles.popupmenu2.Value == 1
elseif handles.popupmenu2.Value == 2
elseif handles.popupmenu2.Value == 3
elseif handles.popupmenu2.Value == 4
elseif handles.popupmenu2.Value == 5
end
elseif handles.popupmenu1.Value == 3
if handles.popupmenu2.Value == 1
elseif handles.popupmenu2.Value == 2
elseif handles.popupmenu2.Value == 3
elseif handles.popupmenu2.Value == 4
elseif handles.popupmenu2.Value == 5
end
elseif handles.popupmenu1.Value == 5
if handles.popupmenu2.Value == 1
elseif handles.popupmenu2.Value == 2
elseif handles.popupmenu2.Value == 3
elseif handles.popupmenu2.Value == 4
elseif handles.popupmenu2.Value == 5
end
end
handles.edittext2.String = sprintf('In those units, the value is %f', convertedValue)
Inside each if block, do the conversion, or get the scaling factor, for the relevant pair that was chosen.
Más respuestas (0)
Ver también
Categorías
Más información sobre Create Large-Scale Model Components en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!