Problem working with popupmenu

1 Ansicht (letzte 30 Tage)
Jhon Rackham
Jhon Rackham am 15 Sep. 2019
Kommentiert: Jhon Rackham am 16 Sep. 2019
Hi guys.
I'm working on GUIDE and i have the next problem:
I have to make a conversor (Decimal, Hexadecimal, octal and bynary)
When i put a number in the edit 1 i have to choose in the "popupmenu1" what value is it (Decimal, Binary, Octal, Hexadecimal) then i choose in the popupmenu2 what value i want convert (Decimal, Binary, Octal, Hexadecimal) and the converted value has to set on the edit2.
mathlab gave me the next message:
"Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)convertidordecantidades('popupmenu2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback."
I hope you guys can help me.
1.png 2.png
%This is my code%
value = str2double(handles.edittext1.String)
if handles.popupmenu1.Value == 1
if handles.popupmenu2.Value == 1
convertedValue = dec2bin(value);
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
convertedValue = dec2base(value,8);
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
convertedValue = dec2base(value,16);
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.edit2.String = sprintf('2.%f',convertedValue)
  30 Kommentare
Walter Roberson
Walter Roberson am 15 Sep. 2019
Consider
ismember('1236', '0':'4')
ismember('1236', ['0':'4', '6':'7'])
Jhon Rackham
Jhon Rackham am 16 Sep. 2019
Thanks Mr Roberson. I have to put it in every case, right?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Large Files and Big Data finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by