# Thread: Creating animated plot of vectors in Matlab

1. ## Creating animated plot of vectors in Matlab

Hi all,

I'm a bit lost on knowing where to start when it comes to creating a 3d animated plot of vectors/points in Matlab/Octave.

Say I have the coordinates for ten points:

x(0) = [5.148,2.905,2.295,6.548,2.093,4.103,4.767,1.666,3. 518,1.709]
y(0) = [5.833,3.600,1.531,7.989,8.538,2.252,8.758,1.164,5. 163,6.452]
z(0) = [6.373,1.143,6.886,1.553,8.662,6.220,8.681,4.049,4. 630,3.772]

x(1) = [5.148,2.905,2.295,6.548,2.093,4.103,4.767,1.666,3. 518,1.709]
y(1) = [5.833,3.600,1.531,7.989,8.538,2.252,8.758,1.164,5. 163,6.452]
z(1) = [6.373,1.143,6.886,1.553,8.662,6.220,8.681,4.049,4. 630,3.772]

x(2) = [5.293,2.612,1.898,6.861,2.301,4.096,4.483,1.885,3. 780,1.921]
y(2) = [5.413,3.900,1.595,8.170,8.311,2.680,8.689,1.182,5. 294,6.694]
z(2) = [6.302,1.056,6.713,1.688,8.524,6.236,8.793,4.310,4. 962,3.673]

and I wanted to see how they evolve in time...ie. maybe 1 second a frame. How could I go about doing this? I know the vector indices are not correct but that's easily changeable. What would be the best way of approaching this problem? I really appreciate any help -- thanks!

JR

2. Here is a quick (and ugly) solution to visualize the points moving:

Code:
clear;clc;close all;

x(1,:) = [5.148,2.905,2.295,6.548,2.093,4.103,4.767,1.666,3.518,1.709];
y(1,:) = [5.833,3.600,1.531,7.989,8.538,2.252,8.758,1.164,5.163,6.452];
z(1,:) = [6.373,1.143,6.886,1.553,8.662,6.220,8.681,4.049,4.630,3.772];

x(2,:) = [5.148,2.905,2.295,6.548,2.093,4.103,4.767,1.666,3.518,1.709];
y(2,:) = [5.833,3.600,1.531,7.989,8.538,2.252,8.758,1.164,5.163,6.452];
z(2,:) = [6.373,1.143,6.886,1.553,8.662,6.220,8.681,4.049,4.630,3.772];

x(3,:) = [5.293,2.612,1.898,6.861,2.301,4.096,4.483,1.885,3.780,1.921];
y(3,:) = [5.413,3.900,1.595,8.170,8.311,2.680,8.689,1.182,5.294,6.694];
z(3,:) = [6.302,1.056,6.713,1.688,8.524,6.236,8.793,4.310,4.962,3.673];

for j = 1:10
for i = 1:3
scatter3(x(i,:),y(i,:),z(i,:),'b','filled')
title(['Data ' num2str(i)])
xlabel x
ylabel y
zlabel z
pause(1)

end
end

It repeats itself 10 times so you can get the idea. Similar things can be done using "quiver" to visualize the vectors.

Regards Elbarto