matlab三维拟合曲线如何平滑拟合数据:x = [28.802 28.557 28.459 28.017 27.919 27.821 27.625 27.428 26.938 26.692 26.545 26.496 26.349 26.202 26.104 26.006 25.907 25.809 25.662 25.564 25.466];y = [8.882 9.127 9.225 9.667 9.765 9.863 10.05
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/25 21:06:31
matlab三维拟合曲线如何平滑拟合数据:x = [28.802 28.557 28.459 28.017 27.919 27.821 27.625 27.428 26.938 26.692 26.545 26.496 26.349 26.202 26.104 26.006 25.907 25.809 25.662 25.564 25.466];y = [8.882 9.127 9.225 9.667 9.765 9.863 10.05
matlab三维拟合曲线如何平滑
拟合数据:x = [28.802 28.557 28.459 28.017 27.919 27.821 27.625 27.428 26.938 26.692 26.545 26.496 26.349 26.202 26.104 26.006 25.907 25.809 25.662 25.564 25.466];
y = [8.882 9.127 9.225 9.667 9.765 9.863 10.059 10.256 10.746 10.992 11.139 11.188 11.335 11.482 11.580 11.678 11.777 11.875 12.022 12.120 12.218];
z = [-6.491 -6.240 -6.142 -5.683 -5.620 -5.603 -5.444 -5.412 -5.415 -5.429 -5.531 -5.588 -5.624 -5.745 -5.851 -5.950 -6.057 -6.162 -6.395 -6.481 -6.500];
x,y代表坐标,z代表该点值
我用plot3拟合出来不光滑,如何才能光滑呢,
matlab三维拟合曲线如何平滑拟合数据:x = [28.802 28.557 28.459 28.017 27.919 27.821 27.625 27.428 26.938 26.692 26.545 26.496 26.349 26.202 26.104 26.006 25.907 25.809 25.662 25.564 25.466];y = [8.882 9.127 9.225 9.667 9.765 9.863 10.05
>> X=[x.*x; y.*y]'
X =
829.5552 78.8899
815.5022 83.3021
809.9147 85.1006
784.9523 93.4509
779.4706 95.3552
774.0080 97.2788
763.1406 101.1835
752.2952 105.1855
725.6558 115.4765
712.4629 120.8241
704.6370 124.0773
702.0380 125.1713
694.2698 128.4822
686.5448 131.8363
681.4188 134.0964
676.3120 136.3757
671.1726 138.6977
666.1045 141.0156
658.5382 144.5285
653.5181 146.8944
648.5172 149.2795
>> b=z'
b =
-6.4910
-6.2400
-6.1420
-5.6830
-5.6200
-5.6030
-5.4440
-5.4120
-5.4150
-5.4290
-5.5310
-5.5880
-5.6240
-5.7450
-5.8510
-5.9500
-6.0570
-6.1620
-6.3950
-6.4810
-6.5000
>> X\b
ans =
-0.0054
-0.0170
>> A=X\b
A =
-0.0054
-0.0170
>> X*A
ans =
-5.7800
-5.7798
-5.7805
-5.7889
-5.7920
-5.7955
-5.8037
-5.8137
-5.8462
-5.8666
-5.8800
-5.8847
-5.8994
-5.9152
-5.9262
-5.9376
-5.9496
-5.9619
-5.9811
-5.9945
-6.0083
>> X*A-b
ans =
0.7110
0.4602
0.3615
-0.1059
-0.1720
-0.1925
-0.3597
-0.4017
-0.4312
-0.4376
-0.3490
-0.2967
-0.2754
-0.1702
-0.0752
0.0124
0.1074
0.2001
0.4139
0.4865
0.4917
>> var(X*A-b)
ans =
0.1308
>> mean(X*A-b)
ans =
-0.0011
>>
clf;clear;
hold on;
axis([3.3000 3.3250 0.0000 0.5500 -0.5500 0.0100]);
x=[3.3000,3.3001,3.3003,3.3004,3.3005,3.3012,3.3019,3.3025,3.3032,3.3055,3.3079,3.3102,3.3125,3.3152,3.3179,3.3206];...
全部展开
clf;clear;
hold on;
axis([3.3000 3.3250 0.0000 0.5500 -0.5500 0.0100]);
x=[3.3000,3.3001,3.3003,3.3004,3.3005,3.3012,3.3019,3.3025,3.3032,3.3055,3.3079,3.3102,3.3125,3.3152,3.3179,3.3206];
y=[0.1000,0.1050,0.1100,0.1150,0.1200,0.1447,0.1690,0.1929,0.2163,0.2934,0.3613,0.4177,0.4610,0.4932,0.5048,0.4951];
z=[-0.5000,-0.4989,-0.4978,-0.4966,-0.4954,-0.4886,-0.4805,-0.4712,-0.4607,-0.4151,-0.3567,-0.2874,-0.2093,-0.1110,-0.0085,0.0941];
%三次样条插值
t1=0:1:15;
t=0:0.01:16;
XX=spline(t1,x,t);
YY=spline(t1,y,t);
ZZ=spline(t1,z,t);
%画点
plot3(XX,YY,ZZ,'r-')
xlabel('X轴');
ylabel('Y轴');
zlabel('Z轴');
收起
plot3不是拟合,只是画图,有什么数据就画什么图而己。
x, y没什么区别,用不着同时来拟合z
z = -318.36 + 23.05*x - 0.4245*x.^2;