电气测试.docx
- 文档编号:6899964
- 上传时间:2023-01-12
- 格式:DOCX
- 页数:18
- 大小:15.75KB
电气测试.docx
《电气测试.docx》由会员分享,可在线阅读,更多相关《电气测试.docx(18页珍藏版)》请在冰豆网上搜索。
电气测试
#include
#include
voidmain(void)
{
inti,n;
double*x,*y,xsum,ysum,xbar,ybar,xycov,xvar,k,b;
FILE*fp;
chartmp[64];
xsum=ysum=xbar=ybar=xycov=xvar=k=b=0.0;
n=0;
fp=NULL;
fp=fopen("e:
\\data-ls.txt","r");
if(fp==NULL)
return;
fscanf(fp,"%s,",tmp);
n=atoi(tmp);
printf("Thedatanumber:
%d\n",n);
x=(double*)malloc(sizeof(double)*n);
y=(double*)malloc(sizeof(double)*n);
for(i=0;i { fscanf(fp,"%s",tmp);; x[i]=atof(tmp); fscanf(fp,"%s",tmp); y[i]=atof(tmp); } fclose(fp); for(i=0;i { xsum+=x[i]; ysum+=y[i]; } xbar=xsum/n; ybar=ysum/n; for(i=0;i { xycov+=(x[i]-xbar)*(y[i]-ybar); xvar+=(x[i]-xbar)*(x[i]-xbar); } k=xycov/xvar; b=ybar-k*xbar; printf("Thelinearequation'skandbis%fand%f.",k,b); free(x); free(y); return; } #include #include #include voidmain() { double*x,xmean,xsum,xsquare_error,xstdev; inti,n; chartmp[64]; FILE*fp; xmean=xsum=xsquare_error=xstdev=0.0; i=n=0; fp=NULL; fp=fopen("e: \\data-rule.txt","r"); if(fp==NULL) return; fscanf(fp,"%s,",tmp); n=atoi(tmp); x=(double*)malloc(sizeof(double)*n); for(i=0;i fscanf(fp,"%s",tmp); x[i]=atof(tmp); xsum+=x[i]; } fclose(fp); fp=NULL; xmean=xsum/n; for(i=0;i xsquare_error+=(x[i]-xmean)*(x[i]-xmean); xstdev=sqrt(xsquare_error/(n-1)); while(i--) { if(fabs(x[i]-xmean)>(3*xstdev)) { printf("Theoutlierisindex%danditsvalueis%f.\n",i,x[i]); free(x); return;//intheexample,theindexis878. } } free(x); return; }} #include #defineMSB0xff #defineST0x10 #defineADDR0x7fff externvoidwrite(intadress,intdi); voiddelay(intclock){ while(clock--); } //producesawwave // voidsaw(void){ inti; for(i=0;i<=MSB;i++){ write(ADDR,i); delay(ST); } i--; for(;i>=0;i--){ write(ADDR,i); delay(ST); } } //producesquarewave //________------------___________------------- // voidsquare(void){ inti; for(i=0;i<=MSB;i++){ write(ADDR,0); delay(ST); } i--; for(;i>=0;i--){ write(ADDR,MSB); delay(ST); } } voidmain(void) { intnsaw,nsquare; nsaw=nsquare=0; //thenumberofwaves,whilegeneratingsaw,nsquareshouldbe0,viceversa. scanf("%d%d",nsaw,nsquare); while(nsaw--) saw(); while(nsquare--) square(); } #include #include voidmain(void) { inti,n; double*x,*y,xsum,ysum,xbar,ybar,xycov,xvar,k,b; FILE*fp; chartmp[64]; xsum=ysum=xbar=ybar=xycov=xvar=k=b=0.0; n=0; fp=NULL; fp=fopen("e: \\data-ls.txt","r"); if(fp==NULL) return; fscanf(fp,"%s,",tmp); n=atoi(tmp); printf("Thedatanumber: %d\n",n); x=(double*)malloc(sizeof(double)*n); y=(double*)malloc(sizeof(double)*n); for(i=0;i { fscanf(fp,"%s",tmp);; x[i]=atof(tmp); fscanf(fp,"%s",tmp); y[i]=atof(tmp); } fclose(fp); for(i=0;i { xsum+=x[i]; ysum+=y[i]; } xbar=xsum/n; ybar=ysum/n; for(i=0;i { xycov+=(x[i]-xbar)*(y[i]-ybar); xvar+=(x[i]-xbar)*(x[i]-xbar); } k=xycov/xvar; b=ybar-k*xbar; printf("Thelinearequation'skandbis%fand%f.",k,b); free(x); free(y); return; } #include #include #include voidmain() { double*x,xmean,xsum,xsquare_error,xstdev; inti,n; chartmp[64]; FILE*fp; xmean=xsum=xsquare_error=xstdev=0.0; i=n=0; fp=NULL; fp=fopen("e: \\data-rule.txt","r"); if(fp==NULL) return; fscanf(fp,"%s,",tmp); n=atoi(tmp); x=(double*)malloc(sizeof(double)*n); for(i=0;i fscanf(fp,"%s",tmp); x[i]=atof(tmp); xsum+=x[i]; } fclose(fp); fp=NULL; xmean=xsum/n; for(i=0;i xsquare_error+=(x[i]-xmean)*(x[i]-xmean); xstdev=sqrt(xsquare_error/(n-1)); while(i--) { if(fabs(x[i]-xmean)>(3*xstdev)) { printf("Theoutlierisindex%danditsvalueis%f.\n",i,x[i]); free(x); return;//intheexample,theindexis878. } } free(x); return; }} #include #defineMSB0xff #defineST0x10 #defineADDR0x7fff externvoidwrite(intadress,intdi); voiddelay(intclock){ while(clock--); } //producesawwave // voidsaw(void){ inti; for(i=0;i<=MSB;i++){ write(ADDR,i); delay(ST); } i--; for(;i>=0;i--){ write(ADDR,i); delay(ST); } } //producesquarewave //________------------___________------------- // voidsquare(void){ inti; for(i=0;i<=MSB;i++){ write(ADDR,0); delay(ST); } i--; for(;i>=0;i--){ write(ADDR,MSB); delay(ST); } } voidmain(void) { intnsaw,nsquare; nsaw=nsquare=0; //thenumberofwaves,whilegeneratingsaw,nsquareshouldbe0,viceversa. scanf("%d%d",nsaw,nsquare); while(nsaw--) saw(); while(nsquare--) square(); } #include #include voidmain(void) { inti,n; double*x,*y,xsum,ysum,xbar,ybar,xycov,xvar,k,b; FILE*fp; chartmp[64]; xsum=ysum=xbar=ybar=xycov=xvar=k=b=0.0; n=0; fp=NULL; fp=fopen("e: \\data-ls.txt","r"); if(fp==NULL) return; fscanf(fp,"%s,",tmp); n=atoi(tmp); printf("Thedatanumber: %d\n",n); x=(double*)malloc(sizeof(double)*n); y=(double*)malloc(sizeof(double)*n); for(i=0;i { fscanf(fp,"%s",tmp);; x[i]=atof(tmp); fscanf(fp,"%s",tmp); y[i]=atof(tmp); } fclose(fp); for(i=0;i { xsum+=x[i]; ysum+=y[i]; } xbar=xsum/n; ybar=ysum/n; for(i=0;i { xycov+=(x[i]-xbar)*(y[i]-ybar); xvar+=(x[i]-xbar)*(x[i]-xbar); } k=xycov/xvar; b=ybar-k*xbar; printf("Thelinearequation'skandbis%fand%f.",k,b); free(x); free(y); return; } #include #include #include voidmain() { double*x,xmean,xsum,xsquare_error,xstdev; inti,n; chartmp[64]; FILE*fp; xmean=xsum=xsquare_error=xstdev=0.0; i=n=0; fp=NULL; fp=fopen("e: \\data-rule.txt","r"); if(fp==NULL) return; fscanf(fp,"%s,",tmp); n=atoi(tmp); x=(double*)malloc(sizeof(double)*n); for(i=0;i fscanf(fp,"%s",tmp); x[i]=atof(tmp); xsum+=x[i]; } fclose(fp); fp=NULL; xmean=xsum/n; for(i=0;i xsquare_error+=(x[i]-xmean)*(x[i]-xmean); xstdev=sqrt(xsquare_error/(n-1)); while(i--) { if(fabs(x[i]-xmean)>(3*xstdev)) { printf("Theoutlierisindex%danditsvalueis%f.\n",i,x[i]); free(x); return;//intheexample,theindexis878. } } free(x); return; }} #include #defineMSB0xff #defineST0x10 #defineADDR0x7fff externvoidwrite(intadress,intdi); voiddelay(intclock){ while(clock--); } //producesawwave // voidsaw(void){ inti; for(i=0;i<=MSB;i++){ write(ADDR,i); delay(ST); } i--; for(;i>=0;i--){ write(ADDR,i); delay(ST); } } //producesquarewave //________------------___________------------- // voidsquare(void){ inti; for(i=0;i<=MSB;i++){ write(ADDR,0); delay(ST); } i--; for(;i>=0;i--){ write(ADDR,MSB); delay(ST); } } voidmain(void) { intnsaw,nsquare; nsaw=nsquare=0; //thenumberofwaves,whilegeneratingsaw,nsquareshouldbe0,viceversa. scanf("%d%d",nsaw,nsquare); while(nsaw--) saw(); while(nsquare--) square(); } #include #include voidmain(void) { inti,n; double*x,*y,xsum,ysum,xbar,ybar,xycov,xvar,k,b; FILE*fp; chartmp[64]; xsum=ysum=xbar=ybar=xycov=xvar=k=b=0.0; n=0; fp=NULL; fp=fopen("e: \\data-ls.txt","r"); if(fp==NULL) return; fscanf(fp,"%s,",tmp); n=atoi(tmp); printf("Thedatanumber: %d\n",n); x=(double*)malloc(sizeof(double)*n); y=(double*)malloc(sizeof(double)*n); for(i=0;i { fscanf(fp,"%s",tmp);; x[i]=atof(tmp); fscanf(fp,"%s",tmp); y[i]=atof(tmp); } fclose(fp); for(i=0;i { xsum+=x[i]; ysum+=y[i]; } xbar=xsum/n; ybar=ysum/n; for(i=0;i { xycov+=(x[i]-xbar)*(y[i]-ybar); xvar+=(x[i]-xbar)*(x[i]-xbar); } k=xycov/xvar; b=ybar-k*xbar; printf("Thelinearequation'skandbis%fand%f.",k,b); free(x); free(y); return; } #include #include #include voidmain() { double*x,xmean,xsum,xsquare_error,xstdev; inti,n; chartmp[64]; FILE*fp; xmean=xsum=xsquare_error=xstdev=0.0; i=n=0; fp=NULL; fp=fopen("e: \\data-rule.txt","r"); if(fp==NULL) return; fscanf(fp,"%s,",tmp); n=atoi(tmp); x=(double*)malloc(sizeof(double)*n); for(i=0;i fscanf(fp,"%s",tmp); x[i]=atof(tmp); xsum+=x[i]; } fclose(fp); fp=NULL; xmean=xsum/n; for(i=0;i xsquare_error+=(x[i]-xmean)*(x[i]-xmean); xstdev=sqrt(xsquare_error/(n-1)); while(i--) { if(fabs(x[i]-xmean)>(3*xstdev)) { printf("Theoutlierisindex%danditsvalueis%f.\n",i,x[i]); free(x); return;//intheexample,theindexis878. } } free(x); return; }} #include #defineMSB
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 电气 测试
![提示](https://static.bdocx.com/images/bang_tan.gif)