MATLAB 3D Plot assistance needed

In summary, the conversation is about plotting a temporal temperature distribution across a metal rod using data from 6 text files. The plot will be in three dimensions, with the z-axis representing the temperature values, the y-axis representing the position along the rod, and the x-axis representing time. To achieve this, the person needs to create a meshgrid and use the surf function. They have attempted to do so but have encountered an error and are seeking further assistance.
  • #1
maxtor101
24
0
Hi guys! Kinda stuck here..

I'm trying to plot the temporal temperature distribution across a metal rod of length 1 meter. The rod is heated at one end and the temperature is measured every 5 cm along the meter rod every 10 minutes for an hour.

Basically I have 6 text files, each containing 20 temperature values. This will go on the z-axis.
Then I have a vector y = [0:5:100]; for the position along the rod. Then I have another vector t containing the times at which i measured the temperature.

So far I've used the load command to read in the data from the text files into 6 vectors. And I have the "position" vector y = [0:5:100]; . I'm not sure how to make this into a three dimensional plot though, I'm very new to matlab.

Any help would be greatly appreciated!
Thanks!
Max
 
Physics news on Phys.org
  • #3
http://www.mathworks.com/help/techdoc/learn_matlab/f3-40352.html

You need to create a meshgrid and use surf.
 
  • #4
Thanks for your reply, however I'm still unsure as to handle the 6 different text files.

Code:
load plot1.txt
load plot2.txt
load plot3.txt
load plot4.txt
load plot5.txt
load plot6.txt

for i=1:6,
    [X] = meshgrid(0:10:60);
    [Y] = meshgrid(0:5:100);       
    [Z] = plot(i);
    mesh(X,Y,Z,'EdgeColor','black')
end

I'm guessing it will be something along the lines of this...?
 
  • #5
But this throws up an error
Code:
 ? Error using ==> mesh at 80
Z must be a matrix, not a scalar or vector.

Error in ==> plots at 14
    mesh(X,Y,Z,'EdgeColor','black')

Any ideas?
 

Related to MATLAB 3D Plot assistance needed

1. How do I plot a 3D graph in MATLAB?

To plot a 3D graph in MATLAB, you can use the plot3 function. This function takes in three arguments: x, y, and z coordinates. You can also customize your graph by setting labels, titles, and adjusting the viewing angle.

2. What is the difference between a 3D scatter plot and a 3D surface plot in MATLAB?

A 3D scatter plot displays individual data points as markers in a 3D space, while a 3D surface plot connects the data points with a surface, creating a continuous representation of the data. Scatter plots are useful for visualizing relationships between variables, while surface plots are better for understanding overall trends and patterns in the data.

3. How can I add a color gradient to my 3D plot in MATLAB?

To add a color gradient to your 3D plot, you can use the colormap function. This function maps a range of values to a specific color scheme, creating a color gradient on your plot. You can also specify the color scheme and range of values to customize the gradient.

4. Can I add a legend to my 3D plot in MATLAB?

Yes, you can add a legend to your 3D plot in MATLAB by using the legend function. This function allows you to specify the labels for each data series and their corresponding colors or markers. You can also customize the position and appearance of the legend.

5. How can I save my 3D plot as an image in MATLAB?

To save your 3D plot as an image, you can use the saveas function. This function takes in your plot handle and the desired file format (such as PNG, JPEG, or TIFF) and saves the plot as an image file. You can also specify the resolution and other properties of the image.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
851
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top