Animation troubles

13 views (last 30 days)
Nathan
Nathan on 14 Jul 2011
Hey all,
I need to make some sort of an animation for sensors and their acceleration readings over time. Ideally, I would want the x and y axes to be the sensors in their appropriate locations (4 arrays of 5 sensors), with the z (vertical) axis being their acceleration reading, while having some sort of animation that changes the z values as time goes on. Something like a spectrogram would work. I have spreadsheets of the acceleration readings of each sensor per unit of time. I have tried movies, animated 3D plots (surf, etc) but to no avail. Can anyone offer any assistance? Thanks in advance.
Nathanf.
SEE BELOW for updated situation
  3 Comments
Nathan
Nathan on 15 Jul 2011
I have recently and successfully implemented an animation where I have the x and y axes representing the literal layout of the sensors in the ground. Then, the z axis is the acceleration reading for each sensor at the corresponding (x,y) point. I plotted it using surf/bar3. I made it an animation by using a for loop that updates the z values of each sensor, then replots the figure and I use M(i) = getframe with each iteration of the loop to update the movie.
Now, where this animation falls short is the lack of play/pause/stop buttons. This is incredibly essential because the whole reason I am constructing this animation tool is to be able to provide a quick and easy way to visualize the data we are collecting as a sort of sanity check, and I've been told that being able to pause and resume at will is pretty essential to this whole animation.
So far, the only way I've found that you can incorporate these play/pause/stop/ff/rewind buttons in Matlab in your figure is through the implay function for image sequences/AVI files.
http://www.mathworks.com/help/toolbox/images/ref/implay.html
Unfortunately, converting each of my generated figures for each unit of time to a jpeg would use up way too much space considering the ridiculous amounts of jpegs that would have to be generated.
BOTTOMLINE: Does anyone know of any ways i can incorporate play/pause features into my animation besides the implay function?
Thanks in advance all.
Patrick Kalita
Patrick Kalita on 18 Jul 2011
You might want to start a new question.

Sign in to comment.

Answers (3)

bym
bym on 15 Jul 2011
how about
waterfall() %?
  1 Comment
Nathan
Nathan on 15 Jul 2011
Works nicely for my situation, but my problem has shifted from actually making an animation to incorporating play/pause buttons into my animation that I have come up with

Sign in to comment.


Walter Roberson
Walter Roberson on 16 Jul 2011
You can write your movie using VideoWriter or (for older versions) move2avi. Once you have done that you can use implay()
Alternately you could probably make small modifications to the videofig user contribution.

hananel byk
hananel byk on 7 Feb 2012
You should use a toggle button and a global variable (or a variable you keep in the handle structure) that would keep the index where you stoped running the animation. Whenever you push the toggle button, it first whether it's on or off, if it's on then it will start a 'while' loop that stops when the animation finish or the 'Value' of the button change back to 0. At the end of the animation the global variable get back to [] (empty). For example: (the button is called play_button)
% --- Executes on button press in play_button. function play_button_Callback(hObject, eventdata, handles) % hObject handle to play_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
global ind %this global variable hold the current index global signal %the signal matrix to plot it's raws
if get(handles.play_button,'Value'); set(handles.play_button,'String','Pause');
if isempty(ind)
k=1;
else
k = ind;
end
while k<=size(signal,1) && get(handles.play_button,'Value');
plot(signal(k,:));
k=k+1
ind=k;
end
if get(handles.play_button,'Value');
kInd = [];
end
else
set(handles.play_button,'String','Play');
end

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!