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

• MATLAB
• Weezix
In summary, the conversation is about creating a 3D plot in MATLAB using the plot3 command and the issue of pairing and connecting points through time. The solution involves using a for loop and the plot3 command to plot the points as a curve without connecting between rows.
Weezix
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

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...

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

## What is MATLAB and how is it used for creating 3D plots?

MATLAB is a programming language and software environment commonly used for scientific and engineering applications. It includes built-in functions and tools for creating and manipulating 3D plots, making it a popular choice for visualizing data in scientific research.

## What are the basic steps for creating a 3D plot in MATLAB?

The basic steps for creating a 3D plot in MATLAB are:

1. Define the data points to be plotted.
2. Use the plot3() function to create a 3D plot using the data points.
3. Customize the plot by adding labels, titles, and legends.
4. Adjust the viewing angle and perspective of the plot using the view() function.
5. Add any additional features, such as grid lines or color maps.

## How can I add multiple data sets to a single 3D plot in MATLAB?

To add multiple data sets to a single 3D plot in MATLAB, use the hold on command before plotting each data set. This will prevent the previous data from being cleared and allow all data sets to be displayed on the same plot.

## Can I export a 3D plot created in MATLAB to another program or format?

Yes, MATLAB allows for easy exporting of 3D plots to other programs or formats. You can use the print() function to save the plot as an image file, or the saveas() function to save it as a figure file. Additionally, you can copy and paste the plot into other programs, such as Microsoft Word or PowerPoint, for further use.

## Are there any tips for improving the appearance of 3D plots in MATLAB?

Yes, there are a few tips for improving the appearance of 3D plots in MATLAB:

• Adjust the viewing angle and perspective using the view() function to clearly visualize the data.
• Use colors and labels to differentiate between different data sets and make the plot more visually appealing.
• Add a color map to represent the data in a more meaningful way.
• Use the grid() function to add grid lines and make it easier to read the plot.
• Experiment with different plot styles and customization options to find the best representation of your data.

• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
5K