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

35 lines
933 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-03 17:02:49 +02:00
void power(long **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-02 15:07:04 +02:00
for(int i = 0; i < nCol-1; i++){
2022-06-01 12:32:04 +02:00
int j = 0;
a[i] = 0;
while(j < nRow-1){
2022-06-02 15:07:04 +02:00
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;
2022-06-01 12:32:04 +02:00
j++;
}
a[i] *= temps;
2022-06-02 15:07:04 +02:00
//printf("%f\n", a[i]);
2022-06-01 12:32:04 +02:00
}
}
int main(int argc , char** argv){
2022-06-03 17:02:49 +02:00
printf("Get raw data mat");
int32_t **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-03 17:02:49 +02:00
freeArray(p,nRow);
2022-06-01 12:32:04 +02:00
}