曲面拟合问题(大侠看看程序帮忙改下参数)
看过论坛上的这篇帖子http://forum.vibunion.com/thread-76746-1-1.html可是不知道自己的程序哪里参数不对,请大侠指教;
function pointandnihe(R)
alpha=0:pi/50:2*pi;%角度
num=1;
a=zeros(87,4);%其中87是根据R=5时得到的点数,a(:,1)是用来记着序号的,后面的a(:,2),a(:,3),a(:,4)是x,y,z三个坐标
for angle=0:pi/(2*R):pi
z=R+R*cos(angle);
r=R*sin(angle);
num=(num-1);
for n=0:round(2*r+2)
x=r*cos(alpha);
y=r*sin(alpha);
hold on;
x1=r*cos(n*2*pi/round(2*r+2));
y1=r*sin(n*2*pi/round(2*r+2));
num=(num+1);
%arrayfun(@(num)text(x1,y1,z,num2str(num)),num)
a(num,1)=round(num);
a(num,2)=x1;
a(num,3)=y1;
a(num,4)=z;
plot3(x1,y1,z,'.')
end
end
a
axis equal
x1=a(:,2);
y1=a(:,3);
z1=a(:,4);
%load aaa
%x1=a(:,2); y1=a(:,3); z1=a(:,4);
ti =0:.1:1; = meshgrid(ti,ti); ZI = griddata(x1,y1,z1,XI,YI);
mesh(XI,YI,ZI), hold;
plot3(x1,y1,z1,'o'); xlabel('x'); ylabel('y'); zlabel('z'); hold off
R=5时 plot3(x1,y1,z,'.')得到的图像如图所示,不知可否将图中得到的点用三角形连接起来,谢谢大侠们了。
页:
[1]