---
title: "使用MATLAB多项式曲线拟合实现"
author: "chungle"
date: "2009-07-11T16:04:58Z"
tags: []
slug: "matlab"
draft: false
lastmod: "2009-07-11T16:04:58Z"
id: 423862
url: "https://chungle.iteye.com/blog/423862"
---

[](http://chungle.iteye.com/admin/blogs/misc.php?action=viewratings&tid=2280971&pid=10241469 "评分 0")使用MATLAB多项式曲线拟合实现

&lt;script&gt;&lt;/script&gt;

%多项式曲线拟合  
x=\[-3.6 -1.8 0 3.3 4 5 6 6.4 7 7.4 8 8.6 9 10 15 26 27 28 29 30 31 32 33 34 35 36 37 38 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100];  
y=\[6.270 6.022 6.016 5.608 5.359 5.360 5.470 5.420 5.350 5.338 5.260 5.205 5.110 5.000 4.735 4.430 4.360 4.370 4.300 4.266 4.180 4.110 4.100 4.040 4.020 3.732 3.502 3.702 3.470 3.398 3.301 3.206 3.050 2.820 2.556 2.448 2.340 2.248 2.166 2.092 2.010 1.950 1.904 1.860 1.820 1.783 1.742 1.702 1.662 1.623 1.583 1.551 1.520 1.485 1.453 1.418 1.392 1.347 1.309 1.298 1.268 1.240 1.212 1.186 1.166 1.132 1.107 1.083 1.057 1.035 1.012 0.991 0.969 0.947 0.924 0.902 0.883 0.857 0.838 0.816 0.796 0.779 0.762 0.743 0.731 0.711 0.695 0.684 0.662];  
n=4; %这里进行四次幂函数，一般用二次的，可以改成2  
p=polyfit(x, y, n); %ployfit(x,y,n)  
xi=linspace(0, 100, 10000);  
z=polyval(p, xi);  
plot(x, y, ' +b ' , x, y,'r', xi, z, ' :g ' );