Assigning a Gif to a push button in a gui

4 views (last 30 days)
I'm trying to make a gif appear when pressing a push button on my gui. I want the gif to appear on my axes called axes2. Can anyone help me out?
  2 Comments
Adam
Adam on 20 Apr 2015
Your question title doesn't seem to match the question body. Do you want to plot the gif on the pushbutton itself or on some totally separate axes when you press the pushbutton?
Robert Mabry
Robert Mabry on 20 Apr 2015
Sorry about that I'm new to this. I want the gif to be displayed on a completely seperate axis when I push the button

Sign in to comment.

Answers (1)

Adam
Adam on 20 Apr 2015
Edited: Adam on 20 Apr 2015
If you create your GUI using GUIDE (which I assume you are if you have an 'axes2') your pushbutton will automatically come with a defined callback that will trigger when you press it. By default this will be something like
pushbutton1_callback( hObject, eventdata, handles )
(though I would recommend changing the ' Tag ' of your button to something meaningful which will also rename that callback for you).
Inside that callback just read in your gif file using
doc imread
(that is a link to the help for the appropriate function, not something to copy verbatim)
and plot it on your axes as e.g.
imshow( imageData, 'Parent', handles.axes2 )
where imageData is what you read in using the imread function.
  2 Comments
Robert Mabry
Robert Mabry on 20 Apr 2015
could you give me an example using a gif file named 'moon.gif'?

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!