matlab将离散点帮我拟合成曲线了(比如使用plot函数)~怎么得到该曲线的公式~比如是一个2次多项式~ 5
2个回答
展开全部
% 给个例子参考
x = [-3.0499 -2.3226 -1.5953 -0.8681 -0.1408 0.5865...
1.3138 2.0410 2.7683 3.4956 4.2229 4.9501];
y = [0.2311 2.1010 3.0167 3.7940 4.2795 4.6146...
4.6146 4.2795 3.7940 3.0167 2.1010 0.2311];
p = polyfit(x,y,2);
xx = min(x):.1:max(x);
yy = polyval(p,xx);
f = poly2str(p,'x');
hold on;
plot(x,y,'bo');
plot(xx,yy,'r-');
legend('原始数据点','2次拟合曲线');
title(['y =' f]);
grid on;
hold off;
x = [-3.0499 -2.3226 -1.5953 -0.8681 -0.1408 0.5865...
1.3138 2.0410 2.7683 3.4956 4.2229 4.9501];
y = [0.2311 2.1010 3.0167 3.7940 4.2795 4.6146...
4.6146 4.2795 3.7940 3.0167 2.1010 0.2311];
p = polyfit(x,y,2);
xx = min(x):.1:max(x);
yy = polyval(p,xx);
f = poly2str(p,'x');
hold on;
plot(x,y,'bo');
plot(xx,yy,'r-');
legend('原始数据点','2次拟合曲线');
title(['y =' f]);
grid on;
hold off;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询