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

32 lines
786 B
C
Raw Normal View History

2022-06-14 10:24:59 +02:00
#include "average.h"
#include "getArray.h"
#include "fileGestion.h"
#include "initialParameters.h"
#include "queue.h"
#include <assert.h>
void averageCalculation(long **p, double averageArray[] , int N, int M){
for(int i = 0; i < M-1; i++){
int j = 0;
averageArray[i] = 0;
while(j < N){
averageArray[i] += p[i][j];
j++;
}
averageArray[i] /= N;
//printf("%f\n", powerArray[i]);
}
}
bool average(char* rawDataFileName,int N , int M){
long **p = getRawDataArray(rawDataFileName,N, M);
double aver[8];
if(p !=NULL){
averageCalculation(p,aver,N,M);
writeDataInFile("averageData.csv",aver,8);
freeArray(p,N);
return true;
}
else{
return false;
}
}