Traitement-signal-plantes/Code-C/power.c
2022-06-02 18:10:42 +02:00

33 lines
871 B
C

#include "power.h"
#include "getArray.h"
#include "fileGestion.h"
#include "initialParameters.h"
void power(int **p, double a[]){
double periode = 1.0/freqEch;
double temps = 1/(nRow * periode);
/*printf("periode : %f\n",periode);
printf("temps : %f\n",temps);*/
//Fill array with the power of the signal for each captor
for(int i = 0; i < nCol-1; i++){
int j = 0;
a[i] = 0;
while(j < nRow-1){
double aire = ( pow(p[j][i+1],2) + pow(p[j+1][i+1],2) ) / 2 * periode;
//printf("aire [%d,%d] : %f\n",j,i,aire);
a[i] += aire;
j++;
}
a[i] *= temps;
//printf("%f\n", a[i]);
}
}
int main(int argc , char** argv){
int **p = getRawDataArray(nRow, nCol);
printArray(p,nRow,nCol);
double pw[8];
power(p,pw);
writePowerData(pw,8);
}