MATLAB: How to change an image (icon) on button into another one image (icon) by clicking on this button in Matlab’s App Designer

app designerMATLAB

Hi everyone,
This is necessary for the audio player for the play/pause button. For example, while the "play" button is pressed, an image (icon) appears on the pause button.
I don't understand how this can be added for a button. I can't find any decision to solve it. I need your help. Thank you for responce!

Best Answer

You will need to do this in the callback of your button.
Assuming that when you create the button, you had set the text to Play and set the Icon file to play icon image.
function ButtonDownFcn(app,event)
switch app.Button.Text
case 'Play'
% do something to play
% change the text and icon

app.Button.Text = 'Pause';
app.Button.Icon = 'Pause.png'; % path to image file

case 'Pause'
% do something to pause
% change the text and icon
app.Button.Text = 'Play';
app.Button.Icon = 'Play.png'; % path to image file
end
end
Related Question