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

  • Thread starter Thread starter Weezix
  • Start date Start date
  • Tags Tags
    3d Matlab Plots
AI Thread Summary
The discussion revolves around creating a 3D plot in MATLAB using the plot3 command, specifically focusing on how to connect data points in a way that does not link them through time. The user initially describes a problem where MATLAB connects points across different time rows, resulting in a line that traverses through time. They seek a solution to plot the X and V variables as a continuous curve at each time point without connecting points from different time rows. A suggested solution involves using a loop to plot each time slice separately, which successfully addresses the user's requirement. The final solution provided effectively allows for the desired visualization of the data.
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:
 
Back
Top