Problem working with popupmenu

1 次查看(过去 30 天)
Jhon Rackham
Jhon Rackham 2019-9-15
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 个评论
Walter Roberson
Walter Roberson 2019-9-15
Consider
ismember('1236', '0':'4')
ismember('1236', ['0':'4', '6':'7'])
Jhon Rackham
Jhon Rackham 2019-9-16
Thanks Mr Roberson. I have to put it in every case, right?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Argument Definitions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by