#include<stdio.h> #include<math.h> #include<stdlib.h>
int main(){ int i=0,k=0,n=0; double sum=0,cossum=0,sinsum=0,data[1024],delta=10.0000E-06; FILE *fp; char csvdata[256]; if ((fp = fopen("data.csv","r")) == NULL){ fprintf(stderr,"No such file (%s)\n","data.csv"); exit(1); } while(fgets(csvdata,256,fp)!=NULL){ data[i]=atof(csvdata); i++; printf("%f\n%f\n",data[i],atof(csvdata)); } fclose(fp); while(k<512){ cossum=0;sinsum=0;sum=0; while(n<1024){ cossum+=(data[n]*(cos(2*M_PI*k*n/1024))); sinsum+=(data[n]*(sin(2*M_PI*k*n/1024))); n++; } sum=pow(delta,2)*(pow(cossum,2)+pow(sinsum,2)); /* printf("%f\n",10*log(sum));*/ k++; } } おうぎゃ
|
No.14667 - 2008/05/09(Fri) 16:45:15
|