Results 1 to 2 of 2

Math Help - Creating animated plot of vectors in Matlab

  1. #1
    Newbie
    Joined
    Jan 2010
    Posts
    6

    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
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    Mar 2007
    Posts
    206
    Awards
    1
    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
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Creating images in Matlab
    Posted in the Math Software Forum
    Replies: 3
    Last Post: June 25th 2011, 07:45 AM
  2. Matlab Help: Creating M-File
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 24th 2010, 09:12 PM
  3. Creating a loop in Matlab help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2010, 04:06 AM
  4. Creating Matlab Median Function
    Posted in the Math Software Forum
    Replies: 8
    Last Post: October 27th 2009, 04:22 PM
  5. MatLab Plot
    Posted in the Math Software Forum
    Replies: 1
    Last Post: August 2nd 2008, 11:59 AM

Search Tags


/mathhelpforum @mathhelpforum