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

32 lines
835 B
C
Raw Normal View History

2022-06-01 12:32:04 +02:00
#include "power.h"
#include "getArray.h"
2022-06-02 14:29:21 +02:00
#include "fileGestion.h"
2022-06-01 18:02:32 +02:00
#include "initialParameters.h"
2022-06-01 12:32:04 +02:00
2022-06-02 14:29:21 +02:00
void power(int **p, double a[]){
double periode = 1.0/freqEch;
double temps = 1/(nRow * periode);
2022-06-02 14:29:21 +02:00
/*printf("periode : %f\n",periode);
printf("temps : %f\n",temps);*/
//Fill array with the power of the signal for each captor
2022-06-01 18:02:32 +02:00
for(int i = 1; i < nCol; i++){
2022-06-01 12:32:04 +02:00
int j = 0;
a[i] = 0;
while(j < nRow-1){
2022-06-01 17:01:23 +02:00
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;
2022-06-01 12:32:04 +02:00
j++;
}
a[i] *= temps;
2022-06-01 12:32:04 +02:00
}
}
int main(int argc , char** argv){
2022-06-01 18:02:32 +02:00
int **p = getRawDataArray(nRow, nCol);
//printArray(p,nRow,nCol);
double pw[8];
power(p,pw);
2022-06-02 14:29:21 +02:00
writePowerData(pw,8);
2022-06-01 12:32:04 +02:00
}