Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

3D Matlab plot

  1. Aug 11, 2009 #1
    Hi All

    I am creating a 3D plot in matlab using the plot3 command. The 3 variables are time (a tx1 vector), X and V (both txn).

    When plotting, matlab pairs the x and v points on the first row, pairs them up and plots, doing this for every row and connecting through time (i.e. matlab draws a line through time for every point (x_i,v_i))

    However I would like it to join the x and v points together, like what would happen if you just plotted (x,v), and not connected through time, and dont know how this can be done, any ideas?

    I hope you guys get what I mean, its not the easiest thing to describe!

    Thanks
     
  2. jcsd
  3. Aug 11, 2009 #2
    I'm not sure I understand what you want, but maybe it's something like this:
    Code (Text):

    hold on;
    for i=1:1:size(x,2)
        plot3(t,x(:,i),v(:,i));
    end
     
    -Kerry
     
  4. Aug 11, 2009 #3
    Not quite...

    Ok so say the first row of x and v are [x1,x2.....xN] and [v1,v2.....vN] respectively. What matlab does is at t=0 plot x against v but only as points, not as a curve. At t=1, it plots the second row, again as points, but now joins (x1,v1) from row one, with the (x1,v1) from row two.

    What I would like is for at t=0, plot x against v as a curve, and not join between the rows...hope this is more clearer...
     
  5. Aug 11, 2009 #4
    OK, how about this:
    Code (Text):

    hold on;
    for i=1:1:size(t)
        plot3(t(i) * ones(size(x,2)), x(i,:), v(i,:));
    end
     
    Getting warmer?

    -Kerry
     
  6. Aug 12, 2009 #5
    Thats more like it! Brilliant, thanks :smile:
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: 3D Matlab plot
  1. Matlab 3D Scatter Plot (Replies: 4)

  2. 3D plot using Matlab (Replies: 1)

  3. MATLAB, 3D plotting (Replies: 1)

Loading...