- 3
- 0
- 约1.11万字
- 约 11页
- 2016-10-15 发布于广东
- 举报
最小二乘法的编实现
最小二乘法:
(用方法计算逆矩阵)
#include stdio.h
#include math.h
#include stdlib.h
#includestring.h
#include iostream.h
#define N 200
#define n 9
void Getdata(double sun[N])//从txt文档中读取数据(小数)
{
char data;
char sunpot[10]={0000000000};//为防止结果出现‘烫’字
int i=0,j=0;
double d;
FILE *fp=fopen(新建文本文档.txt,r);
if(!fp)
{
printf(cant open file\n);
}
while(!feof(fp))
{
data=fgetc(fp);
if(data!=\n)
{
sunpot[i]=data;
i++;
}
else if(data==\n)
{
sunpot[i]=\0;//给定结束符
d=atof(sunpot);//将字符串转换成浮点数
sun[j]=d;
j++;
i=0;//将i复位
}
}
}
void Normal(double sun[N],double sun1[N])//将数据进行标准化
{
原创力文档

文档评论(0)