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

42 lines
1.1 KiB
C
Raw Normal View History

2023-06-01 17:22:38 +02:00
#include "./Include/initialParameters.h"
#include "./Include/fileGestion.h"
#include "./Include/getArray.h"
#include "./Include/growthRate.h"
2022-06-15 11:57:15 +02:00
/**
* @brief calculate de growth rate between to point next to each other
2023-06-01 17:22:38 +02:00
*
2022-06-15 11:57:15 +02:00
* @param dataArray array with data of points next to each other for each captor (dim : 2 * nCols)
* @param gRateArray array that contaigns results of the growth ratecalculation
*/
2023-06-01 17:22:38 +02:00
void growthRateCalculation(double **dataArray, double *gRateArray)
{
for (int i = 0; i < nCol - 1; i++)
{
2022-06-16 14:35:02 +02:00
gRateArray[i] = (dataArray[0][i] - dataArray[1][i]) / period;
2022-06-15 11:57:15 +02:00
}
}
2022-06-16 14:35:02 +02:00
/**
* @brief calcul then print differentiate in csv
2023-06-01 17:22:38 +02:00
*
* @param dataLign
2022-06-16 14:35:02 +02:00
*/
2023-06-01 17:22:38 +02:00
void growthRateFunction(double **dataLign, char *fileName)
{
double gRateArray[nCol - 1];
growthRateCalculation(dataLign, gRateArray);
appendDataInFile(fileName, gRateArray, nCol - 1);
2022-06-16 17:05:12 +02:00
}
2023-06-01 17:22:38 +02:00
void sumColArray(long **p, double res[], int N, int M)
{
for (int i = 1; i < M; i++)
{
2022-06-16 17:05:12 +02:00
int j = 0;
res[i] = 0;
2023-06-01 17:22:38 +02:00
while (j < N)
{
2022-06-16 17:05:12 +02:00
res[i] += p[i][j];
j++;
}
}
2022-06-15 11:57:15 +02:00
}