animation : movie + comet in one figure (subplots)

조회 수: 1 (최근 30일)
N
N 2014년 9월 1일
댓글: Geoff Hayes 2014년 9월 2일
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
N
N 2014년 9월 1일
This is what I have so far, now both come in one figure but only the comet code runs, the bar3c does not change-animate
figure(1)
set(gca,'NextPlot','replaceChildren');
for i = 1:length(emg2)
subplot(2,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)];
bar3c(abs(extensors))
subplot(2,1,2)
comet(data.pg2{1,1}(:,1))
F(i) = getframe;
end
movie(F,1)
Geoff Hayes
Geoff Hayes 2014년 9월 2일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by