matlab中的曲面拟合问题 10
现在我已知了多组函数z=(x,y)数据(已有一关于数据的txt文档),想通过matlab近似的还原出z=(x,y)的函数,忘高手指教。...
现在我已知了多组函数z=(x,y)数据(已有一关于数据的txt文档),想通过matlab近似的还原出z=(x,y)的函数,忘高手指教。
展开
展开全部
clc;clear
U=[0 10 20 30 50 100];
V=[1.5:0.5:10];
Z=[0 0 0 0 0 0 ;
0 0.11627907 0.23255814 0.348837209 0.465116279 0.581395349 ;
0 0.340909091 0.511363636 0.681818182 0.852272727 1.022727273 ;
0 0.813953488 1.162790698 1.511627907 1.627906977 1.744186047 ;
0 1.193181818 1.704545455 2.301136364 2.556818182 2.727272727 ;
0 1.860465116 2.325581395 3.255813953 3.488372093 3.953488372 ;
0 2.215909091 2.897727273 3.835227273 4.6875 5.795454545 ;
0 2.790697674 3.488372093 4.418604651 5.813953488 7.441860465 ;
0 3.323863636 4.346590909 5.625 7.159090909 9.801136364 ;
0 3.837209302 5.23255814 6.511627907 8.372093023 11.27906977 ;
0 4.517045455 6.221590909 7.755681818 10.14204546 13.63636364 ;
0 5.11627907 6.860465116 8.604651163 11.51162791 15.23255814 ;
0 5.625 7.670454545 9.715909091 12.86931818 17.30113636 ;
0 6.046511628 8.372093023 10.58139535 13.8372093 18.72093023 ;
0 6.5625 9.119318182 11.59090909 15.34090909 20.625 ;
0 6.976744186 9.651162791 12.20930233 15.93023256 21.62790698 ;
0 7.5 10.48295455 13.125 17.04545455 23.26704546 ;
0 7.558139535 10.81395349 13.37209302 17.20930233 24.76744186 ;];
[X,Y]=meshgrid(U,V)
[XI,YI]=meshgrid(0:1:100,1.5:0.1:10)%NaN问题出现在这里,换一下位置即可。
ZI=interp2(X,Y,Z,XI,YI);
figure(1)
surf(XI,YI,ZI)
p=polyfit2d(XI,YI,ZI,3,3);%这个是什么意思?
figure(2)
datafit=polyval2d(p,XI,YI);
surf(XI,YI,datafit)
U=[0 10 20 30 50 100];
V=[1.5:0.5:10];
Z=[0 0 0 0 0 0 ;
0 0.11627907 0.23255814 0.348837209 0.465116279 0.581395349 ;
0 0.340909091 0.511363636 0.681818182 0.852272727 1.022727273 ;
0 0.813953488 1.162790698 1.511627907 1.627906977 1.744186047 ;
0 1.193181818 1.704545455 2.301136364 2.556818182 2.727272727 ;
0 1.860465116 2.325581395 3.255813953 3.488372093 3.953488372 ;
0 2.215909091 2.897727273 3.835227273 4.6875 5.795454545 ;
0 2.790697674 3.488372093 4.418604651 5.813953488 7.441860465 ;
0 3.323863636 4.346590909 5.625 7.159090909 9.801136364 ;
0 3.837209302 5.23255814 6.511627907 8.372093023 11.27906977 ;
0 4.517045455 6.221590909 7.755681818 10.14204546 13.63636364 ;
0 5.11627907 6.860465116 8.604651163 11.51162791 15.23255814 ;
0 5.625 7.670454545 9.715909091 12.86931818 17.30113636 ;
0 6.046511628 8.372093023 10.58139535 13.8372093 18.72093023 ;
0 6.5625 9.119318182 11.59090909 15.34090909 20.625 ;
0 6.976744186 9.651162791 12.20930233 15.93023256 21.62790698 ;
0 7.5 10.48295455 13.125 17.04545455 23.26704546 ;
0 7.558139535 10.81395349 13.37209302 17.20930233 24.76744186 ;];
[X,Y]=meshgrid(U,V)
[XI,YI]=meshgrid(0:1:100,1.5:0.1:10)%NaN问题出现在这里,换一下位置即可。
ZI=interp2(X,Y,Z,XI,YI);
figure(1)
surf(XI,YI,ZI)
p=polyfit2d(XI,YI,ZI,3,3);%这个是什么意思?
figure(2)
datafit=polyval2d(p,XI,YI);
surf(XI,YI,datafit)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询