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

38 lines
1 KiB
C

#include "average.h"
#include "getArray.h"
#include "fileGestion.h"
#include "initialParameters.h"
#include "queue.h"
/**
* @brief realize the average calcul
*
* @param p array with all the values that will be used for the calcul
* @param averageArray array where results are stocked
*/
void averageCalculation(long **p, double averageArray[]){
for(int i = 1; i < nCol; i++){
int j = 0;
averageArray[i] = 0;
while(j < nRow -1){
averageArray[i] += p[i][j];
j++;
}
averageArray[i] /= nRow;
//printf("%f\n", powerArray[i]);
}
}
/**
* @brief function that realize all the action to write one lign in the file averageData.csv
*
* @param rawDataFileName name of the raw data file to use to realize the calcul
*/
void average(char* rawDataFileName){
long **p = getRawDataArray(rawDataFileName);
double aver[nCol -1];
if(p !=NULL){
averageCalculation(p,aver);
appendDataInFile("averageData.csv",aver,nCol-1);
freeArray(p,nRow);
}
}