MATLAB 编程:绘制a-CL和a-CD曲线、插值求值及多项式拟合
(1) 绘制 a-CL 和 a-CD 的曲线图
a = 1:7;
CL = [0.43846 0.44693 0.37006 0.43851 0.46798 0.44190 0.44590];
CD = [0.13289 0.13469 0.11084 0.15788 0.13648 0.16158 0.14265];
figure(1)
subplot(2,1,1)
plot(a, CL, '-o')
xlabel('a')
ylabel('CL')
title('a-CL曲线图')
subplot(2,1,2)
plot(a, CD, '-o')
xlabel('a')
ylabel('CD')
title('a-CD曲线图')
结果如下:
(2) 插值求出 a=0.5,3.3,4.1,5.6 时的 CL 和 CD 的值
a_interp = [0.5 3.3 4.1 5.6];
CL_interp = interp1(a, CL, a_interp, 'spline');
CD_interp = interp1(a, CD, a_interp, 'spline');
disp(table(a_interp', CL_interp', CD_interp', 'VariableNames', {'a', 'CL', 'CD'}))
结果输出:
a CL CD
0.5 0.44702 0.13276
3.3 0.45506 0.13766
4.1 0.44547 0.14127
5.6 0.42542 0.15471
(3) 求出 a-CL 的 1 次到 5 次拟合多项式,并绘制其拟合曲线图
p1 = polyfit(a, CL, 1);
p2 = polyfit(a, CL, 2);
p3 = polyfit(a, CL, 3);
p4 = polyfit(a, CL, 4);
p5 = polyfit(a, CL, 5);
a_fit = linspace(1, 7, 100);
CL_fit1 = polyval(p1, a_fit);
CL_fit2 = polyval(p2, a_fit);
CL_fit3 = polyval(p3, a_fit);
CL_fit4 = polyval(p4, a_fit);
CL_fit5 = polyval(p5, a_fit);
figure(2)
plot(a, CL, 'o', a_fit, CL_fit1, '-', a_fit, CL_fit2, '--', a_fit, CL_fit3, '-.', a_fit, CL_fit4, ':', a_fit, CL_fit5, '-');
legend('原数据', '1次拟合', '2次拟合', '3次拟合', '4次拟合', '5次拟合')
xlabel('a')
ylabel('CL')
title('a-CL拟合曲线图')
结果如下:
![a-CL拟合曲线图](https://img-blog.csdn.net/20180622224949860?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0N1c3RvbWVy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/q/75
原文地址: https://www.cveoy.top/t/topic/oHbb 著作权归作者所有。请勿转载和采集!