필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Can I use a function as a conditional statement?

조회 수: 1 (최근 30일)
Kristen O'Mara
Kristen O'Mara 2018년 3월 5일
마감: MATLAB Answer Bot 2021년 8월 20일
I'm working with my first GUI using the guide and I need to make a GUI with two pushbuttons. When pushbutton 1 is pressed, pushbutton 2 must display 'push me' and turn red. When either button is pressed, it should go back to being a white button with no text. In my current function, pushbutton 2 turns red and says 'push me' correctly and turns white with no text when you click it. However, I can't figure out how to get pushbutton 2 tow turn white with no text when pushbutton one is pressed. I tried using the call to that function in a conditional statement but I don't think you can do that.
Here is what I tried with the conditional statement:
function pushbutton1_Callback(hObject, eventdata, handles)
handles.pushbutton2.BackgroundColor = [1 0 0];
handles.pushbutton2.String = 'push me';
if pushbutton1_Callback(hObject, eventdata, handles) &&handles.pushbutton2.BackgroundColor = [1 0 0] &&
handles.pushbutton2.String = 'push me'
handles.pushbutton2.BackgroundColor = [1 1 1];
handles.pushbutton2.String = ' ';
end
I did this because in the code for the GUI there is a comment that says
% --- Executes on button press in pushbutton1.
Also I'm sure there is a better way to hide the text on the button than setting the string to a bunch of spaces, that was just my first thought.

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by