Animation in GUI matlab
3 views (last 30 days)
Show older comments
Hello.. I am a student working on my senior project I am beginner in matlab, I just want to ask, if I want to make an animation in GUIDE.. I want to move pictures very fast so it seems like the picture is moving without pressing any push button or scalar just when the GUI opens pics start changing.. or is their any other way to show kind of movie in GUI ?? Thanks
0 Comments
Accepted Answer
Geoff Hayes
on 15 Nov 2014
Edited: Geoff Hayes
on 15 Nov 2014
Noorah - yes, you can show a kind of movie in a GUI that plays as soon as you launch it. Suppose that your GUI has a single axes (named/tagged as axes1) that will be used to show your images/frames. In the OpeningFcn of your GUI, create a list of all the images that you want to show (in the order that they are to be shown) and save this list to the handles structure. Use the dir function to get that list (which will be an array of objects for each file that matches the filter).
Now, you want to show the images without any user interaction which you can do using a timer. The Period of the timer will be your frame rate - so if the timer fires every one second, then a new image will be shown every one second. The number of times to execute the timer, TasksToExecute, will be the number of images that you have to show. You will need to supply a callback function that will be invoked every second (or whatever period you have chosen), something like 'TimerFcn',{@timerCallback,handles.figure1} where we pass an additional input which is the name of the figure, assumed to be figure1.
Once you have done this, you can save the updated handles structure using guidata, and start the timer.
Now you need to define your timer callback which will have a signature like
function [] = timerCallback(~,~,guiHandle)
4 Comments
Geoff Hayes
on 17 Nov 2014
Noorah - look at lines 59-62
handles.folder = ...
'/Users/geoff/Development/bitbucket_repos/matlab/image_proc/images';
handles.filter = '*.jpg1';
handles.imgList = dir(fullfile(handles.folder,handles.filter));
As you don't have the folder from above, then the image list, handles.imgList will be empty and the TasksToExecute set to zero. You need to provide your own folder with your own images...
More Answers (0)
See Also
Categories
Find more on Animation 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!