Surface/contour plot

15 次查看(过去 30 天)
Bry S
Bry S 2011-4-11
Hi everyone! I am new again to using MATLAB. I have a set of three-variable data that are numerically given. How will I go and generate a 3D plot/surface/contour? I need to specify the data and use any of the functions available to plot. One of the first I did was to place all the values in excel: I placed all X-values in column A, all Y-values in column B, and all Z-values in column C. I invoked xlsread to have them mapped to MATLAB. However, I dont seem to get a good plot/contour?
What seems to be wrong. The final graph does not give the correct Xs, Ys, and Zs. Please help. thanks

采纳的回答

Walter Roberson
Walter Roberson 2011-4-11
Are your x and y data on a grid, or are they scattered around?
And which MATLAB version are you using?
If you do not need a surface, then scatter3() might be what you want.
  2 个评论
Bry S
Bry S 2011-4-12
I need to have a contour or a surface plot as a final output. My x and y data are equally spaced from each other with a corresponding z value for each x and y (if this is what is meant by x and y data on a grid). Please help. thanks very much.

请先登录,再进行评论。

更多回答(1 个)

John D'Errico
John D'Errico 2011-4-11
This is a problem of scattered data. Such data, not already filling a nice uniform grid, is not directly plot-able as a surface, because MATLAB does not know how those scattered points connect together into that surface. Your eyes/brain are very good at interpreting things as a surface.
If the data does form a simple surface, that could in theory be written in the form
z = f(x,y)
then you can use tools in MATLAB to do this. One option is to generate a gridded surface, using a tool like my gridfit, as found on the file exchange.
It will create a nice smooth surface, that surf can plot, or that you can use with the contour function to do as you wish.
If perhaps you do not wish for a complete grid, perhaps if gridfit would do too much extrapolation to suit you on a strangely shaped data domain, then you can use tricontour, also found for download from the file exchange. Or, you could use delaunay to triangulate your data, and then apply trimesh, or trisurf to the result.
  1 个评论
Bry S
Bry S 2011-6-12
Hi there! Your suggestion on how to generate 3D surface plots with scattered data fits best to my problem. However, I do not know the steps for me to be able to place the function to the Matlab 7.8.0 I am using.
How to go about placing the gridfit function to my computer? Please provide me the necessary steps from what file to place and where to place so that I can use gridfit. Thanks

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by