multiple power ok

This commit is contained in:
quentin.perret 2022-06-02 14:29:21 +02:00
parent b904f19500
commit 8339796927
8 changed files with 26 additions and 800026 deletions

View file

@ -1,9 +1,10 @@
CC = gcc CC = gcc
all: all:
rm powerData.csv
$(CC) b2hd.c -o b2hd $(CC) b2hd.c -o b2hd
$(CC) fileGestion.c getArray.c power.c -lm -o power $(CC) fileGestion.c getArray.c power.c -lm -o power
#getArray.c fileGestion.c power.c main.c -o main #getArray.c fileGestion.c power.c main.c -o main
./b2hd < ../02400031.TXT > rawData.txt ./b2hd < ../02400031.TXT > rawData.csv
./power ./power

View file

@ -2,8 +2,8 @@
void clearRawData(int N){ void clearRawData(int N){
char buffer[256]; char buffer[256];
FILE *f = fopen("newFile.txt","w+"); FILE *f = fopen("newFile.csv","w+");
FILE *g = fopen("rawData.txt","r"); FILE *g = fopen("rawData.csv","r");
for(int i = 0; i < N; i++){ for(int i = 0; i < N; i++){
fgets(buffer , sizeof buffer , g); fgets(buffer , sizeof buffer , g);
//printf("Line contaigns: %s" , buffer); //printf("Line contaigns: %s" , buffer);
@ -12,5 +12,16 @@ void clearRawData(int N){
if(!fgets(buffer,sizeof buffer , g)) break; if(!fgets(buffer,sizeof buffer , g)) break;
fprintf(f,"%s",buffer); fprintf(f,"%s",buffer);
} }
remove("rawData.txt"); rename("newFile.txt", "rawData.txt"); remove("rawData.csv"); rename("newFile.csv", "rawData.csv");
}
void writePowerData(double a[], int N){
FILE *f = fopen("powerData.csv","a+");
for(int i = 0 ; i < N ; i++){
if( i < N-1){
fprintf(f, "%f , ", a[i]);
} else {
fprintf(f, "%f\n", a[i]);
}
}
} }

View file

@ -4,3 +4,4 @@
#include <stdlib.h> #include <stdlib.h>
void clearRawData(int N); void clearRawData(int N);
void writePowerData(double a[], int N);

View file

@ -16,7 +16,7 @@ void fillRawData(int** p, int N, int M) {
int i, j; int i, j;
char buffer[200]; char buffer[200];
char *token; char *token;
FILE *f = fopen("rawData.txt","r"); FILE *f = fopen("rawData.csv","r");
for(i = 0 ; i < N ; i++){ for(i = 0 ; i < N ; i++){
if (!fgets(buffer, sizeof buffer, f)) break; // condition d'arret de la boucle si fichier fini if (!fgets(buffer, sizeof buffer, f)) break; // condition d'arret de la boucle si fichier fini
@ -37,8 +37,7 @@ void fillRawData(int** p, int N, int M) {
void printArray(int** p, int N, int M) { void printArray(int** p, int N, int M) {
int i, j; int i, j;
for(i = 0 ; i < N ; i++) for(i = 0 ; i < N ; i++)
for(j = 0 ; j < M ; j++) printf("%d , %d , %d , %d , %d , %d , %d , %d\n",p[i][0],p[i][1],p[i][2],p[i][3],p[i][4],p[i][5],p[i][6],p[i][7]);
printf("array[%d][%d] = %d\n", i, j, p[i][j]);
} }
void freeArray(int** p, int N) { void freeArray(int** p, int N) {

Binary file not shown.

View file

@ -1,13 +1,14 @@
#include "power.h" #include "power.h"
#include "getArray.h" #include "getArray.h"
#include "fileGestion.h"
#include "initialParameters.h" #include "initialParameters.h"
void *power(int **p, double a[]){ void power(int **p, double a[]){
double periode = 1.0/freqEch; double periode = 1.0/freqEch;
double temps = 1/(nRow * periode); double temps = 1/(nRow * periode);
printf("periode : %f\n",periode); /*printf("periode : %f\n",periode);
printf("temps : %f\n",temps); printf("temps : %f\n",temps);*/
//Fill array with the power of the signal for each captor //Fill array with the power of the signal for each captor
for(int i = 1; i < nCol; i++){ for(int i = 1; i < nCol; i++){
@ -27,7 +28,5 @@ int main(int argc , char** argv){
//printArray(p,nRow,nCol); //printArray(p,nRow,nCol);
double pw[8]; double pw[8];
power(p,pw); power(p,pw);
for(int i = 1 ; i < nCol ; i++){ writePowerData(pw,8);
printf("power c°%d : %f\n",i,pw[i]);
}
} }

View file

@ -1,3 +1,3 @@
#include <math.h> #include <math.h>
void *power(int **p, double a[]); void power(int **p, double a[]);

File diff suppressed because it is too large Load diff