필터 지우기
필터 지우기

Problem working with popupmenu

조회 수: 1 (최근 30일)
Jhon Rackham
Jhon Rackham 2019년 9월 15일
댓글: Jhon Rackham 2019년 9월 16일
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에서 Large Files and Big Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by