Azzera filtri
Azzera filtri

How work with 2 popup menus

1 visualizzazione (ultimi 30 giorni)
Jhon Rackham
Jhon Rackham il 1 Set 2019
Commentato: Jhon Rackham il 2 Set 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. :D12.png

Risposta accettata

Image Analyst
Image Analyst il 2 Set 2019
Modificato: Image Analyst il 2 Set 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.

Più risposte (0)

Categorie

Scopri di più su MATLAB Report Generator in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by