有谁知道为什么MATLAB的“分段三次插值”在二维曲面拟合中给出对角化的绘图数据?附件是使用此立方拟合的代码的二维曲面图(在代码和数据下方)。可以看出,图像/图中的峰在五个隔离的数据点(指向左上到右下)对角化。而不是预期的对称高斯传播。为什么立方插值会这样做?
立方体拟合显示在:http://www.mathworks.co.uk/help/curvefit/fit.html
下面是带有'分段三次插值'的matlab代码,用于拟合以下数据:
'helm2Coils126.txt'& 'positionsData2_20x20_2.txt'。
对此的任何帮助都会非常感激。
提前感谢你,
Brendan Darrer
================================ CODE ============== =======================
% 2D MIT surface plots of p.d. phase-difference against x y coordinates
% Written by Brendan Darrer
% Date 20th September 2013.
% oscillator = 2.6V at f = 500Hz, lock-in amplifier: sensitivity = 50mV, time constant = 500ms.
% background phase: ---- degrees.
A = load('helm2Coils126.txt')
B = load('positionsData2_20x20_2.txt')
% correcting phase offset
for i=1:10 % columns
for j=1:40 % rows
if (A(j,i) < 0) % correct offset, if e.g. phase = -179 when it should be 181.
A(j,i) = 360 + A(j,i);
end
end
end
p = A';
A2 = p(:)'
A = A2'
B = [B A]
x=B(:,1); y=B(:,2); z=B(:,3);
Fig2Handle = figure('Position', [100, 100, 1049, 895]);
xlin=linspace(min(x),max(x),100); % was 50
ylin=linspace(min(y),max(y),100); % was 50
[X,Y]=meshgrid(xlin,ylin);
% cubic piecewise interpolation:
Z=griddata(x,y,z,X,Y,'cubic');
surf(X,Y,Z) % interpolated
axis tight; hold on
view(0,90);
plot3(x,y,z,'.','MarkerSize',10)
colormap hsv
colorbar
xlabel('x axis / mm')
ylabel('y axis / mm')
zlabel('phase \Delta\phi / degrees')
======================代码结束====================== =======
%====== helm2Coils126.txt ==== copy&amp;粘贴到.txt文件中========
%====================(10列,40行)===================== < / p>
-14.690 -144.460 -173.610 -177.820 -179.260 -179.930 179.690 179.580 179.340 179.360
-128.020 -175.360 -177.990 -179.420 179.680 179.420 179.330 179.170 179.160 179.120
-175.050 -178.450 -179.890 179.770 179.350 179.140 179.070 179.070 178.990 178.960
-178.060 -179.590 179.550 179.290 179.070 179.040 178.940 178.870 178.890 178.900
-179.270 179.780 179.360 179.130 178.990 178.910 178.880 178.940 178.730 178.470
-178.900 179.730 179.160 179.000 179.000 178.860 178.900 179.080 178.760 179.450
179.430 -179.870 179.350 179.220 178.910 178.980 178.950 178.990 178.870 178.520
-179.930 179.220 179.040 179.070 178.940 178.840 178.840 178.810 178.810 178.880
179.430 179.130 179.000 179.000 178.850 178.840 178.820 178.800 178.860 178.840
179.370 179.070 178.930 178.880 178.860 178.810 178.880 178.830 178.810 178.790
179.320 179.120 179.000 178.900 178.860 178.840 178.830 178.870 178.860 178.800
179.360 179.140 178.990 178.920 178.880 178.840 178.890 178.860 178.840 178.900
179.470 179.170 178.950 178.960 178.950 178.860 178.840 178.850 178.860 178.830
179.700 179.190 179.060 -2.820 178.860 178.910 178.850 178.840 178.790 178.840
179.870 179.440 179.250 179.020 179.000 178.970 178.870 178.850 178.820 178.850
-179.450 179.690 179.290 179.030 178.920 178.900 178.890 178.870 178.840 178.850
-177.830 -179.580 179.600 179.270 179.090 178.980 178.950 178.880 178.860 178.890
-175.210 -178.450 -179.850 179.560 179.200 179.080 178.960 178.990 178.930 178.910
-129.050 -175.360 -178.460 -179.730 179.650 179.370 179.250 179.120 179.100 179.040
-16.750 -121.430 -175.270 -178.000 -179.460 179.230 179.330 179.400 179.580 -179.960
179.260 179.350 179.520 179.600 179.900 -179.300 -177.900 -174.010 -107.820 -15.650
179.050 179.090 179.140 179.240 179.440 179.650 -179.680 -174.620 -175.350 -107.820
178.920 178.910 178.940 179.050 179.140 179.260 179.550 -179.970 -178.710 -174.930
178.810 178.870 178.870 178.930 178.990 179.040 179.180 179.470 -179.810 -178.250
178.740 178.850 178.840 178.870 178.910 179.030 179.130 179.380 179.840 -178.840
178.460 178.720 178.760 178.760 178.820 178.870 179.040 178.980 179.430 179.750
178.730 178.770 178.790 178.790 178.840 178.810 178.920 179.060 179.220 179.620
178.780 178.840 178.810 178.780 178.820 178.810 178.870 178.950 179.170 179.360
178.910 178.820 178.910 -2.710 178.830 178.830 178.870 178.900 -2.900 179.240
178.840 178.840 178.870 178.840 178.820 178.840 178.810 178.920 179.020 179.300
178.870 178.870 178.870 178.800 178.800 178.700 178.760 178.840 179.040 179.300
178.890 178.840 178.790 178.690 178.480 177.550 178.480 178.860 179.080 179.250
178.740 178.840 178.820 178.760 177.590 -93.940 177.420 178.890 179.120 179.340
178.970 178.840 178.770 178.740 178.520 177.530 178.700 178.990 179.090 179.570
178.830 178.800 178.800 178.760 178.760 178.780 178.830 179.000 179.290 179.810
178.820 178.900 178.840 178.940 178.940 178.920 178.960 179.130 179.410 -179.960
178.970 178.990 178.900 178.960 178.910 179.040 179.190 179.540 -179.930 -178.180
-2.790 179.060 179.040 179.050 179.110 179.320 179.710 -179.720 -178.270 -174.540
179.000 179.140 179.210 179.440 179.410 179.750 -179.470 -177.830 -167.850 -20.630
179.220 179.290 179.400 179.780 179.900 -179.470 -178.300 -171.660 -168.110 -22.730
=========================结束第一个文本文件================== ==========
======= positionsData2_20x20_2.txt ======== copy&amp;粘贴到.txt文件中=========
===================(2列,400行)===================== =========
0 247
13 247
26 247
39 247
52 247
65 247
78 247
91 247
104 247
117 247
0 234
13 234
26 234
39 234
52 234
65 234
78 234
91 234
104 234
117 234
0 221
13 221
26 221
39 221
52 221
65 221
78 221
91 221
104 221
117 221
0 208
13 208
26 208
39 208
52 208
65 208
78 208
91 208
104 208
117 208
0 195
13 195
26 195
39 195
52 195
65 195
78 195
91 195
104 195
117 195
0 182
13 182
26 182
39 182
52 182
65 182
78 182
91 182
104 182
117 182
0 169
13 169
26 169
39 169
52 169
65 169
78 169
91 169
104 169
117 169
0 156
13 156
26 156
39 156
52 156
65 156
78 156
91 156
104 156
117 156
0 143
13 143
26 143
39 143
52 143
65 143
78 143
91 143
104 143
117 143
0 130
13 130
26 130
39 130
52 130
65 130
78 130
91 130
104 130
117 130
0 117
13 117
26 117
39 117
52 117
65 117
78 117
91 117
104 117
117 117
0 104
13 104
26 104
39 104
52 104
65 104
78 104
91 104
104 104
117 104
0 91
13 91
26 91
39 91
52 91
65 91
78 91
91 91
104 91
117 91
0 78
13 78
26 78
39 78
52 78
65 78
78 78
91 78
104 78
117 78
0 65
13 65
26 65
39 65
52 65
65 65
78 65
91 65
104 65
117 65
0 52
13 52
26 52
39 52
52 52
65 52
78 52
91 52
104 52
117 52
0 39
13 39
26 39
39 39
52 39
65 39
78 39
91 39
104 39
117 39
0 26
13 26
26 26
39 26
52 26
65 26
78 26
91 26
104 26
117 26
0 13
13 13
26 13
39 13
52 13
65 13
78 13
91 13
104 13
117 13
0 0
13 0
26 0
39 0
52 0
65 0
78 0
91 0
104 0
117 0
130 247
143 247
156 247
169 247
182 247
195 247
208 247
221 247
234 247
247 247
130 234
143 234
156 234
169 234
182 234
195 234
208 234
221 234
234 234
247 234
130 221
143 221
156 221
169 221
182 221
195 221
208 221
221 221
234 221
247 221
130 208
143 208
156 208
169 208
182 208
195 208
208 208
221 208
234 208
247 208
130 195
143 195
156 195
169 195
182 195
195 195
208 195
221 195
234 195
247 195
130 182
143 182
156 182
169 182
182 182
195 182
208 182
221 182
234 182
247 182
130 169
143 169
156 169
169 169
182 169
195 169
208 169
221 169
234 169
247 169
130 156
143 156
156 156
169 156
182 156
195 156
208 156
221 156
234 156
247 156
130 143
143 143
156 143
169 143
182 143
195 143
208 143
221 143
234 143
247 143
130 130
143 130
156 130
169 130
182 130
195 130
208 130
221 130
234 130
247 130
130 117
143 117
156 117
169 117
182 117
195 117
208 117
221 117
234 117
247 117
130 104
143 104
156 104
169 104
182 104
195 104
208 104
221 104
234 104
247 104
130 91
143 91
156 91
169 91
182 91
195 91
208 91
221 91
234 91
247 91
130 78
143 78
156 78
169 78
182 78
195 78
208 78
221 78
234 78
247 78
130 65
143 65
156 65
169 65
182 65
195 65
208 65
221 65
234 65
247 65
130 52
143 52
156 52
169 52
182 52
195 52
208 52
221 52
234 52
247 52
130 39
143 39
156 39
169 39
182 39
195 39
208 39
221 39
234 39
247 39
130 26
143 26
156 26
169 26
182 26
195 26
208 26
221 26
234 26
247 26
130 13
143 13
156 13
169 13
182 13
195 13
208 13
221 13
234 13
247 13
130 0
143 0
156 0
169 0
182 0
195 0
208 0
221 0
234 0
247 0
===================结束第二个文本文件======================== ==
答案 0 :(得分:1)
你确定要显示的情节吗?以下是您的数据代码获得的结果。我正在使用Matlab 2012a。
答案 1 :(得分:0)
数据的立方分段插值在MATLAB 2012b和MATLAB 2013a中生成2D曲面图(如原始问题中所示)。但是我在matlab Interpolations找到了散乱数据的其他插值,其中包括:'linear' - &gt;线性插值; '立方' - &gt;立方分段插值; '自然' - &gt;自然邻域插值; '最近' - &gt;最近邻插值。
'自然邻居'给出了与x和y中数据最接近平滑的高斯样边缘。然而,我坚持使用三次插值,因为它在图像的z分量中给出了圆形曲线。然而,'自然邻居'插值会在z分量中产生尖锐的尖峰,这对我的数据来说是不切实际的。
以下是2个表面图,显示了“自然邻居”和“立方分段”插值之间的差异,对于金属容器中铜盘的示例图像,取自涡流成像。