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!

  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)
  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,:));
    Getting warmer?

  6. Aug 12, 2009 #5
    Thats more like it! Brilliant, thanks :smile:
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook