void lsm_test(void)
{
float32_t a,b;
static float32_t tempx[96] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.46667, 11.4667,
31.6, 52.7333, 80.3333, 116.333, 156.6, 199.4, 242.2, 283.4,
329.2, 379.333, 431.333, 482.6, 541, 594.4, 643.533, 692.133,
736.267, 772.667, 810.133, 841.867, 868.2, 892.4, 917.667,
939.8, 954.667, 969, 976.8, 983.4, 987.467, 994.933, 1023.67,
875.2, 873.933, 758.8, 678.2, 515.867, 782.533, 908.8, 779.2,
831.4, 645.533, 734.067, 679.533, 610.267, 565.067, 512.467,
462, 405.2, 354.133, 302, 247.8, 191.533, 140, 94.2667, 57.5333,
25.9333, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // x
static float32_t tempy[96] = {0.595, 0.595, 0.595, 0.595, 0.595, 0.595,
0.595, 0.595, 0.595, 0.595, 0.595, 0.595, 0.595, 0.595, 0.595,
0.595, 0.595, 0.595, 0.595, 0.595, 0.595, 0.595, 0.595, 0.595, 0.595,
0.595, 0.595, 0.595, 0.595, 0.595, 0.595, 0.595, 1.785, 2.57833, 3.927,
5.79233, 7.379, 9.48133, 11.1473, 12.4167, 13.6627, 16.193701, 18.248699,
19.042, 19.042, 19.105301, 16.6383, 17.240999, 14.631, 11.8217, 11.663,
12.155, 15.488, 21.859301, 19.32, 19.042, 19.6133, 21.105, 22.9937,
20.827299, 23.858299, 23.0333, 19.2883, 15.6937, 21.5893, 23.802999,
20.518299, 21.5893, 17.907301, 17.971001, 17.574301, 16.781, 15.5513,
12.3773, 10.2747, 8.60867, 6.86333, 5.39567, 3.88767, 2.856, 2.142,
2.142, 0.952, 0.952, 0.952, 0.952, 0.952, 0.952, 0.952, 0.952, 0.952, 0.952,
0.952, 0.952, 0.952, 0.952 }; // y
leastSquareLinearFit(tempx,tempy,96,&a,&b);
printf("a=%f b=%f",a,b);
}
四、主函数