MATLAB 多項式フィッティング
matlab を使用して多項式近似を実現するのは比較的簡単で、数行のコマンドで実現できます。
clc;clear;
close all;
len = 20; % 数据长度
x = 1:1:len; % 时间轴坐标
y = x.^6; % 生成6次多项式
figure,plot(x,y,'o');
xlabel('Position / s');
ylabel('Intencity / cd');
title('Input Signal');
% 多项式拟合
coef = polyfit(x,y,4); % 拟合4阶多项式
coee = polyval(coef,x); % 使用拟合系数生成以x为坐标的多项式
hold on,plot(x,coee); % 绘图命令
legend('Initial Curve','Fitting Curve');
フィッティング効果は以下の通りです。