/*
曲线拟合
int CurveFitter(int x_data_addr, float* y_data);
y_data--------输入--y数据
返回值-------最大值下标
*/
#define rank_ 3
float atemp[2 * (rank_ + 1)] = { 0 };
float b[rank_ + 1] = { 0 };
float a[rank_ + 1][rank_ + 1];
float fit_data[60];
int CurveFitter(float* y_data)
{
atemp[1] =0;
atemp[2] =0;
atemp[3] =0;
atemp[4] =0;
atemp[5] =0;
atemp[6] =0;
b[0] =0;
b[1] =0;
b[2] =0;
b[3] =0;
for (int i = 0; i < 60; i++)
{
atemp[1] =atemp[1]+i;
atemp[2] =atemp[2]+i*i; //atemp[2] =atemp[2]+ pow(i,2);
atemp[3] =atemp[3]+i*i*i;//atemp[2] =atemp[2]+ pow(i,3);
atemp[4] =atemp[4]+i*i*i*i;//atemp[2] =atemp[2]+ pow(i,4);
atemp[5] =atemp[5]+i*i*i*i*i;//atemp[2] =atemp[2]+ pow(i,5);
atemp[6] =atemp[6]+i*i*i*i*i*i;//atemp[2] =atemp[2]+ pow(i,6);
b[0] +
最小二乘法拟合曲线
于 2021-04-15 17:47:52 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)