str1 = fopen('boat.txt','r');
data1 = fscanf(str1,'%f',inf);
t=data1(1:7:26754,1);
x1=data1(2:7:26754,1);
y1=data1(3:7:26754,1);
z1=data1(4:7:26754,1);
x2=data1(5:7:26754,1);
y2=data1(6:7:26754,1);
z2=data1(7:7:26754,1);
k1=(x1)';
m1=(y1)';
l1=(z1)';
k2=(x2)';
m2=(y2)';
l2=(z2)';
plot3(k1,m1,l1);hold on
plot3(k2,m2,l2);hold off
grid on
theAxes=axis;
m=moviein(8000);
for i=1:10:3822
plot3(k1(i),m1(i),l1(i),'.');
hold on
plot3(k2(i),m2(i),l2(i),'*');
hold off
str=strcat('t=',num2str(t(i,1)));
text(k1(i)+10,m1(i),l1(i),str);
grid on
axis(theAxes);
m(:,i)=getframe;
end
movie(m,10);
这是我实现两个动点同时运动的源程序
然后加进去背景如下: |