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

33 lines
878 B
C

#include "power.h"
#include "getArray.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 = 1; i < nCol; i++){
int j = 0;
a[i] = 0;
while(j < nRow-1){
double aire = ( pow(p[j][i],2) + pow(p[j+1][i],2) ) / 2 * periode;
//printf("aire [%d,%d] : %f\n",j,i,aire);
a[i] += aire;
j++;
}
a[i] *= temps;
}
}
int main(int argc , char** argv){
int **p = getRawDataArray(nRow, nCol);
//printArray(p,nRow,nCol);
double pw[8];
power(p,pw);
for(int i = 1 ; i < nCol ; i++){
printf("power c°%d : %f\n",i,pw[i]);
}
}