Surface/contour plot

조회 수: 5 (최근 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.
Walter Roberson
Walter Roberson 2011년 4월 12일
surf(x,y,z)

댓글을 달려면 로그인하십시오.

추가 답변 (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