Traitement-signal-plantes/Code-C/power.c

35 lines
933 B
C

#include "power.h"
#include "getArray.h"
#include "fileGestion.h"
#include "initialParameters.h"
void power(long **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){
printf("Get raw data mat");
int32_t **p = getRawDataArray(nRow, nCol);
//printArray(p,nRow,nCol);
double pw[8];
power(p,pw);
writePowerData(pw,8);
freeArray(p,nRow);
}