用matlab拟合下面一组数据的曲线x=[-2.30259,-1.60944,-1.20397,-0.91629,-0.69315,-0.51083,-0.35667,-0.22314,-0.10536,0.00000,0.40546,0.69315,0.91629,1.09861,1.25276,1.38629,1.50408,1.60944,1.70475,1.79176];y=[2.48491,3.06805,3.21888,3.31419,
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/30 19:22:59
![用matlab拟合下面一组数据的曲线x=[-2.30259,-1.60944,-1.20397,-0.91629,-0.69315,-0.51083,-0.35667,-0.22314,-0.10536,0.00000,0.40546,0.69315,0.91629,1.09861,1.25276,1.38629,1.50408,1.60944,1.70475,1.79176];y=[2.48491,3.06805,3.21888,3.31419,](/uploads/image/z/4070739-3-9.jpg?t=%E7%94%A8matlab%E6%8B%9F%E5%90%88%E4%B8%8B%E9%9D%A2%E4%B8%80%E7%BB%84%E6%95%B0%E6%8D%AE%E7%9A%84%E6%9B%B2%E7%BA%BFx%3D%5B-2.30259%2C-1.60944%2C-1.20397%2C-0.91629%2C-0.69315%2C-0.51083%2C-0.35667%2C-0.22314%2C-0.10536%2C0.00000%2C0.40546%2C0.69315%2C0.91629%2C1.09861%2C1.25276%2C1.38629%2C1.50408%2C1.60944%2C1.70475%2C1.79176%5D%3By%3D%5B2.48491%2C3.06805%2C3.21888%2C3.31419%2C)
用matlab拟合下面一组数据的曲线x=[-2.30259,-1.60944,-1.20397,-0.91629,-0.69315,-0.51083,-0.35667,-0.22314,-0.10536,0.00000,0.40546,0.69315,0.91629,1.09861,1.25276,1.38629,1.50408,1.60944,1.70475,1.79176];y=[2.48491,3.06805,3.21888,3.31419,
用matlab拟合下面一组数据的曲线
x=[-2.30259,-1.60944,-1.20397,-0.91629,-0.69315,-0.51083,-0.35667,-0.22314,-0.10536,0.00000,0.40546,0.69315,0.91629,1.09861,1.25276,1.38629,1.50408,1.60944,1.70475,1.79176];
y=[2.48491,3.06805,3.21888,3.31419,3.41773,3.44681,3.50556,3.52636,3.57235,3.61092,3.87950,3.92395,4.03247,4.13517,4.20916,4.28496,4.34898,4.41158,4.45898,4.60116];
a=polyfit(x,y,6);
yi=polyval(a,x);
plot(x,y,'o',x,yi,'r')
这是我写的程序,可是曲线的效果不是太好,对拟合的阶数作了变化,还是不行,图形如下,能使的那条曲线更加光滑一点.
用matlab拟合下面一组数据的曲线x=[-2.30259,-1.60944,-1.20397,-0.91629,-0.69315,-0.51083,-0.35667,-0.22314,-0.10536,0.00000,0.40546,0.69315,0.91629,1.09861,1.25276,1.38629,1.50408,1.60944,1.70475,1.79176];y=[2.48491,3.06805,3.21888,3.31419,
%xi重新取值
clear
x=[-2.30259,-1.60944,-1.20397,-0.91629,-0.69315,...
-0.51083,-0.35667,-0.22314,-0.10536,0.00000,...
0.40546,0.69315,0.91629,1.09861,1.25276,1.38629,...
1.50408,1.60944,1.70475,1.79176];
y=[2.48491,3.06805,3.21888,3.31419,3.41773,3.44681,...
3.50556,3.52636,3.57235,3.61092,3.87950,3.92395,...
4.03247,4.13517,4.20916,4.28496,4.34898,4.41158,...
4.45898,4.60116];
a=polyfit(x,y,6);
xi=linspace(min(x),max(x),length(x));
yi=polyval(a,xi);
plot(x,y,'o',xi,yi,'r')