animation : movie + comet in one figure (subplots)
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I would like to plot two different animations in one figure. One the one hand I have a comet plot:
comet(data.pg{1,1});
And then I have an animation of a bar plot:
axis tight manual;
set(gca,'NextPlot','replaceChildren');
for i = 1:length(emg2{1,1})
extensors = [emg2{1,1}(i,1:5);emg2{1,1}(i,6:10);emg2{1,1}(i,11:15);emg2{1,1}(i,16:20);emg2{1,1}(i,21:25);emg2{1,1}(i,26:30);emg2{1,1}(i,31:35);emg2{1,1}(i,36:40);emg2{1,1}(i,41:45)];
bar3(abs(extensors))
F(i) = getframe;
end
movie(fig,F,1)
Now I want both animations to run at the same time and in the same figure but in subplots. I used a code but it doesn't work. Can anybody help ?
axis tight manual;
set(gca,'NextPlot','replaceChildren');
for i = 1:length(emg2{1,1})
subplot(1,2,1);
extensors = [emg2{1,1}(i,1:5);emg2{1,1}(i,6:10);emg2{1,1}(i,11:15);emg2{1,1}(i,16:20);emg2{1,1}(i,21:25);emg2{1,1}(i,26:30);emg2{1,1}(i,31:35);emg2{1,1}(i,36:40);emg2{1,1}(i,41:45)];
bar3(abs(extensors))
subplot(1,2,2);
comet(data.pg{1,1});
F(i) = getframe;
end
movie(F,1)
4 Kommentare
Geoff Hayes
am 2 Sep. 2014
Have you stepped through the code to see what the length of emg2 is? Try doing this, and especially observe the behaviour of comet. This function is an animation, so as soon as you execute the statement
comet(data.pg2{1,1}(:,1))
the animation will begin and end before the next iteration of the for loop. So if the loop is supposed to iterate 100 times, then the same comet animation will play 100 times. If you want the comet to advance by one frame at each iteration (given that you have code to capture a frame), then you may have to rethink the use of comet in your code and manually advance the data.pg2 to the next "frame" or position.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Animation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!