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
Click For Summary

Discussion Overview

The discussion revolves around creating a 3D plot in MATLAB using the plot3 command, specifically focusing on how to plot two variables (X and V) against time without connecting the points through time. Participants explore different coding approaches to achieve this visualization.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant describes the issue of MATLAB connecting points through time when using the plot3 command and seeks a solution to plot points without these connections.
  • Another participant suggests a loop to plot each point in a way that might address the issue, but it is unclear if this meets the original request.
  • A further clarification is provided, emphasizing the need to plot each row of X and V as a curve without connecting them between different time rows.
  • A revised suggestion is made to plot the data by fixing the time value for each row, which appears to be closer to the desired outcome.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the initial approach, but there is a progression towards a solution with some suggestions being more aligned with the original request than others.

Contextual Notes

There are assumptions about the structure of the data (e.g., dimensions of X and V) that are not explicitly stated, which may affect the applicability of the proposed solutions.

Who May Find This Useful

Individuals working with MATLAB who are interested in 3D plotting techniques, particularly those looking to visualize data without temporal connections between points.

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:
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K