Problem working with popupmenu

1 view (last 30 days)
Jhon Rackham
Jhon Rackham on 15 Sep 2019
Commented: Jhon Rackham on 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 Comments
Walter Roberson
Walter Roberson on 15 Sep 2019
Consider
ismember('1236', '0':'4')
ismember('1236', ['0':'4', '6':'7'])
Jhon Rackham
Jhon Rackham on 16 Sep 2019
Thanks Mr Roberson. I have to put it in every case, right?

Sign in to comment.

Answers (0)

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!