admin 管理员组

文章数量: 1184232

二次函数拟合

clear
clc
% 拟合
figure
N = 20;
x = linspace(-2,2,N);
x = x';
r = 0.25*randn(N,1);
y = x.^4+r; % 原方程
subplot(1,3,1);
f1 = fit(x,y,'poly1');   % 线性
plot(f1,x,y,'o');
legend(subplot(1,3,1),'off');
subplot(1,3,2);
f2 = fit(x,y,'poly2');   % 二次
plot(f2,x,y,'o

本文标签: 二次函数拟合