0

我有一个 1001x2 的矩阵,每列代表振荡器的相位角。我正在尝试制作一个 matlab 电影,以便我在时间 t 绘制两个相位角,一次绘制一个。所以基本上它应该看起来像 2 个点在圆周上移动。如果我坚持情节,那么它似乎是正确的,除了所有点都在框架上。但如果我不坚持,那么每次迭代中只会显示第二个图(每帧只有一个红色 *)。知道发生了什么事以及如何使两个点都显示在每一帧上吗?

fig1=figure(1);
winsize = get(fig1,'Position');
winsize(1:2) = [0 0];
numframes=100;
A=moviein(numframes,fig1,winsize);
set(fig1,'NextPlot','replacechildren')
i=1;

%hold on
for frame=1:numframes
i=frame*10;
plot(cos(mod(y(i),2*pi)),sin(mod(y(i),2*pi)),'bo');
plot(cos(mod(y(i,2),2*pi)) *1.1,sin(mod(y(i,2),2*pi))*1.15,'r*'); %only this one is shown
axis([-1.5 1.5 -1.5 1.5])
A(:,i)=getframe(fig1,winsize);
end 
4

1 回答 1

1

好吧,您可以hold on在画框期间和画框hold off结束时。像

 for frame=1:numframes
 i=frame*10;

 plot(cos(mod(y(i),2*pi)),sin(mod(y(i),2*pi)),'bo');   
 hold on   % // here
 plot(cos(mod(y(i,2),2*pi)) *1.1,sin(mod(y(i,2),2*pi))*1.15,'r*');
 axis([-1.5 1.5 -1.5 1.5])
 A(:,i)=getframe(fig1,winsize);
 hold off  % // and here
 end 

但在这种情况下,你可以简单地做

 ....
 plot(cos(mod(y(i),2*pi)),sin(mod(y(i),2*pi)),'bo', ... 
     cos(mod(y(i,2),2*pi)) *1.1,sin(mod(y(i,2),2*pi))*1.15,'r*');
于 2012-12-02T19:16:19.830 回答