How can I create a 3D plot in MATLAB without connecting points through time?

  • Context: MATLAB 
  • Thread starter Thread starter Weezix
  • Start date Start date
  • Tags Tags
    3d Matlab Plots
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 15K views
Weezix
Messages
3
Reaction score
0
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 don't know how this can be done, any ideas?

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

Thanks
 
Physics news on Phys.org
I'm not sure I understand what you want, but maybe it's something like this:
Code:
hold on;
for i=1:1:size(x,2)
    plot3(t,x(:,i),v(:,i));
end

-Kerry
 
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...
 
OK, how about this:
Code:
hold on;
for i=1:1:size(t)
    plot3(t(i) * ones(size(x,2)), x(i,:), v(i,:));
end

Getting warmer?

-Kerry
 
Thats more like it! Brilliant, thanks :smile: