简体   繁体   English

在Matlab / Freemat中绘制3D表面图

[英]Plot 3d surface plot in matlab/freemat

I would like to ask about 3d surface plotting. 我想问一下3D表面绘图。 As I am new to it, I was just trying out. 当我刚接触它时,我只是在尝试。 Basically, I have 3 parameters, x, y ,z which I have the values from experimental datas and I would like to plot them out. 基本上,我有3个参数x,y,z,这些参数来自实验数据,我想将其绘制出来。 As such, i tried, 因此,我尝试了

x= [6 7 8 9 10 11 12 1]
x =
  6  7  8  9 10 11 12  1
--> y=[2 3 4 5 6 1 6 8]
y =
 2 3 4 5 6 1 6 8
--> z= [3 4 5 6 7 8 9 10]
z =
  3  4  5  6  7  8  9 10
meshgrid(x,y,z)
surf(x,y,z)

The plot window did come out but there was no graph. 绘图窗口确实出现了,但是没有图形。 Is my method wrong? 我的方法错了吗?

Thanks! 谢谢!

It sounds like you need to start with plot3 , as you're just describing a set of points in 3D, rather than points on a mesh or surface. 听起来您需要从plot3开始,因为您只是以3D描述一组点,而不是网格或曲面上的点。 See if that does what you want. 看看是否满足您的要求。

x = [6 7 8 9 10 11 12 1];
y = [2 3 4 5 6 1 6 8];
z = [3 4 5 6 7 8 9 10];
plot3(x, y, z, '.');

This is how I would plot a surface : 这就是我要绘制表面的方式:

%define the data 
x=[6 7 8 9 10 11 12 1 6 7 8 9 10 11 12 1];
y=[2 3 4 5 6 1 6 8 2 3 4 5 6 1 6 8];
z=[3 4 5 6 7 8 9 10 3 4 5 6 7 8 9 10];

%Create 3D surface
[X,Y]=meshgrid(x,y);
Z=griddata(x,y,z,X,Y);

%Plot the surface
surface(X,Y,Z);
shading interp %makes it look sexy
%xlim([])
%ylim([])

Sometimes I use axis limets to make the plot look nicer (eliminates the unneeded white area's); 有时我使用轴标注使图看起来更好(消除了不需要的白色区域)。 for this set of data I could use xlim([6 11]) and ylim([2 6]). 对于这组数据,我可以使用xlim([6 11])和ylim([2 6])。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM