Help and Support - GUIDE

조회 수: 2 (최근 30일)
Gbola
Gbola 2021년 1월 3일
댓글: Steven Lord 2021년 1월 4일
I have two pop-up menus (popupmenu1 and popupmenu2) each of them contains three strings, namely; “red”, “blue” and “green”; one pushbutton (pushbutton1); and one edittext (edittext1) placed on a figure (figure1).
If I press the pushbutton1, I need It to display the name of the new (resultant) colour formed in the edittext1, as a result of mixing (combining) the selected colour from popupmenu1 with the selected colour from popupmenu2.
The desired outputs are:
red + green = yellow (that is, selection of “red” from popupmenu1 and selection of “green” from popupmenu2 will display “yellow” in the edittext1, when the pushbutton1 is pressed).
Similarly:
red + blue = magenta (that is, selection of “red” from popupmenu1 and selection of “blue” from popupmenu2 will display “magenta” in the edittext1, when the pushbutton1 is pressed).
blue + green = cyan (that is, selection of “blue” from popupmenu1 and selection of “green” from popupmenu2 will display “cyan” in the edittext1, when the pushbutton1 is pressed).
The Callback needs to be implemented using nested If-elseif-else-end or the Switch statements to run.
Many thanks.
  댓글 수: 3
Gbola
Gbola 2021년 1월 4일
I have placed all of the UI controls mentioned in the question on a figure (figure1).
I have written a callback for pushbutton1.
The specific question: How do I get the name of the new (resultant) colour displayed in the edittext1, after I had mixed (combined) two colours by selecting one colour from popupmenu1 and another from popupmenu2, and lastly pressed pushbutton1?
For instance, red + green = yellow (that is, on selecting “red” from popupmenu1 and "green” from popupmenu2, "yellow" will be displayed in edittext1, when pushbutton1 is pressed).
See the below callback for pushbutton1:
function pushbutton1_Callback(hobject,eventdata,handles)
if strcmp( selected_string1, 'red') && strcmp( selected_string2, ’blue')
set(handles.edittext1,'String','Magenta' )
elseif strcmp( selected_string1, 'green') && strcmp( selected_string2, 'blue')
set(handles.edittext1,'String','Cyan' )
elseif strcmp( selected_string1, 'red') && strcmp( selected_string2, 'green')
set(handles.edittext1,'String’,'Yellow' )
else
set(handles.edittext1,'String', 'Yiou need to select one colour from each pop-up menu' )
end
Error message displayed by Matlab: Error in Callbacck.
I look forward to hearing from you.
Many thanks.
Steven Lord
Steven Lord 2021년 1월 4일
Can you show us the full and exact text of the error message you receive? Show us all the text displayed in red and all the text displayed in orange when you try pushing the button.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by