金牌会员
- 积分
- 2947
- 威望
- 1774
- 贡献
- 469
- 兑换币
- 705
- 注册时间
- 2012-4-22
- 在线时间
- 352 小时
- 毕业学校
- hgd
|
5#
楼主 |
发表于 2013-7-5 11:51:17
|
只看该作者
牛博 发表于 2013-7-5 11:13
看看程序
float Leastk[2] = {0.0},Leastb[2] = {0.0};
float XSum = 0.0,YSum = 0.0,XYSum = 0.0,X2Sum = 0.0; //x为行数,y为中线
if(track.ucHangEN[0] > 10){
for(i = 1;i <= track.ucHangEN[0];i++){
XSum += i;
YSum += track.ucMiddle;
XYSum += (float)i * track.ucMiddle;
X2Sum += i * i;
}
Leastk[0] = 10 * ((track.ucHangEN[0]) * XYSum - XSum * YSum) / ((track.ucHangEN[0]) * X2Sum - XSum * XSum);
Leastb[0] = (X2Sum * YSum - XSum * XYSum) / ((track.ucHangEN[0]) * X2Sum - XSum * XSum);
}else {
Leastk[0] = Leastk[1];
Leastb[0] = Leastb[1];
}
}
|
|