Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Can I use a function as a conditional statement?

1 visualizzazione (ultimi 30 giorni)
Kristen O'Mara
Kristen O'Mara il 5 Mar 2018
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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.

Risposte (0)

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by