matlab曲面拟合现在有12对坐标XY=[-16287.0 7583.2 -16289.6 7582.7 -16284
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/18 14:13:38
matlab曲面拟合
现在有12对坐标
XY=[
-16287.0 7583.2
-16289.6 7582.7
-16284.8 7583.5
-16287.4 7587.6
-16277.7 7576.1
-16310.9 7562.4
-16337.5 7565.5
-16340.1 7587.8
-16315.9 7583.6
-16378.6 7580.3
-16413.3 7565.4
-16412.7 7609.4
-16352.5 7608.5
-16295.1 7608.3
-16323.9 7655.2
]
以及对应的浓度值
Conc=[
4.12E+03
2.29E+04
9.27E+03
940
265
837
4.0
2.7
5.8
1.0
3.9
1.2
2.0
0.5
0.8
]
请问如何拟合得出平面内任意点的浓度值
现在有12对坐标
XY=[
-16287.0 7583.2
-16289.6 7582.7
-16284.8 7583.5
-16287.4 7587.6
-16277.7 7576.1
-16310.9 7562.4
-16337.5 7565.5
-16340.1 7587.8
-16315.9 7583.6
-16378.6 7580.3
-16413.3 7565.4
-16412.7 7609.4
-16352.5 7608.5
-16295.1 7608.3
-16323.9 7655.2
]
以及对应的浓度值
Conc=[
4.12E+03
2.29E+04
9.27E+03
940
265
837
4.0
2.7
5.8
1.0
3.9
1.2
2.0
0.5
0.8
]
请问如何拟合得出平面内任意点的浓度值
二维插值
用函数interp2()进行二维插值.该函数调用的一般形式为:
ZI=interp2(X,Y,Z,XI,YI,method)
其中,Z是一个矩形数组,包含二维函数的值,X和Y为大小相同的数组,包含相对于Z的给定值.XI和YI为包含插值点数据的矩阵,
method表示插值方法:
(1)最近邻插值(method='nearest')
(2)双线性插值(method='linear')
(3)双三次插值(method='cubic')
Example 1. Interpolate the peaks function over a finer grid.
[X,Y] = meshgrid(-3:.25:3);
Z = peaks(X,Y);
[XI,YI] = meshgrid(-3:.125:3);
ZI = interp2(X,Y,Z,XI,YI);
mesh(X,Y,Z), hold, mesh(XI,YI,ZI+15)
hold off
axis([-3 3 -3 3 -5 20])
Example 2. Given this set of employee data, years = 1950:10:1990;
service = 10:10:30;
wage = [150.697 199.592 187.625
179.323 195.072 250.287
203.212 179.092 322.767
226.505 153.706 426.730
249.633 120.281 598.243];
it is possible to interpolate to find the wage earned in 1975 by an employee with 15 years' service: w = interp2(service,years,wage,15,1975)
w =
190.6287
用函数interp2()进行二维插值.该函数调用的一般形式为:
ZI=interp2(X,Y,Z,XI,YI,method)
其中,Z是一个矩形数组,包含二维函数的值,X和Y为大小相同的数组,包含相对于Z的给定值.XI和YI为包含插值点数据的矩阵,
method表示插值方法:
(1)最近邻插值(method='nearest')
(2)双线性插值(method='linear')
(3)双三次插值(method='cubic')
Example 1. Interpolate the peaks function over a finer grid.
[X,Y] = meshgrid(-3:.25:3);
Z = peaks(X,Y);
[XI,YI] = meshgrid(-3:.125:3);
ZI = interp2(X,Y,Z,XI,YI);
mesh(X,Y,Z), hold, mesh(XI,YI,ZI+15)
hold off
axis([-3 3 -3 3 -5 20])
Example 2. Given this set of employee data, years = 1950:10:1990;
service = 10:10:30;
wage = [150.697 199.592 187.625
179.323 195.072 250.287
203.212 179.092 322.767
226.505 153.706 426.730
249.633 120.281 598.243];
it is possible to interpolate to find the wage earned in 1975 by an employee with 15 years' service: w = interp2(service,years,wage,15,1975)
w =
190.6287