multiple power ok
This commit is contained in:
parent
b904f19500
commit
8339796927
|
@ -1,9 +1,10 @@
|
|||
CC = gcc
|
||||
|
||||
all:
|
||||
rm powerData.csv
|
||||
$(CC) b2hd.c -o b2hd
|
||||
$(CC) fileGestion.c getArray.c power.c -lm -o power
|
||||
#getArray.c fileGestion.c power.c main.c -o main
|
||||
|
||||
./b2hd < ../02400031.TXT > rawData.txt
|
||||
./b2hd < ../02400031.TXT > rawData.csv
|
||||
./power
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
void clearRawData(int N){
|
||||
char buffer[256];
|
||||
FILE *f = fopen("newFile.txt","w+");
|
||||
FILE *g = fopen("rawData.txt","r");
|
||||
FILE *f = fopen("newFile.csv","w+");
|
||||
FILE *g = fopen("rawData.csv","r");
|
||||
for(int i = 0; i < N; i++){
|
||||
fgets(buffer , sizeof buffer , g);
|
||||
//printf("Line contaigns: %s" , buffer);
|
||||
|
@ -12,5 +12,16 @@ void clearRawData(int N){
|
|||
if(!fgets(buffer,sizeof buffer , g)) break;
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,3 +4,4 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
void clearRawData(int N);
|
||||
void writePowerData(double a[], int N);
|
|
@ -16,7 +16,7 @@ void fillRawData(int** p, int N, int M) {
|
|||
int i, j;
|
||||
char buffer[200];
|
||||
char *token;
|
||||
FILE *f = fopen("rawData.txt","r");
|
||||
FILE *f = fopen("rawData.csv","r");
|
||||
for(i = 0 ; i < N ; i++){
|
||||
|
||||
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) {
|
||||
int i, j;
|
||||
for(i = 0 ; i < N ; i++)
|
||||
for(j = 0 ; j < M ; j++)
|
||||
printf("array[%d][%d] = %d\n", i, j, p[i][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]);
|
||||
}
|
||||
|
||||
void freeArray(int** p, int N) {
|
||||
|
|
BIN
Code-C/power
BIN
Code-C/power
Binary file not shown.
|
@ -1,13 +1,14 @@
|
|||
#include "power.h"
|
||||
#include "getArray.h"
|
||||
#include "fileGestion.h"
|
||||
#include "initialParameters.h"
|
||||
|
||||
void *power(int **p, double a[]){
|
||||
void power(int **p, double a[]){
|
||||
|
||||
double periode = 1.0/freqEch;
|
||||
double temps = 1/(nRow * periode);
|
||||
printf("periode : %f\n",periode);
|
||||
printf("temps : %f\n",temps);
|
||||
/*printf("periode : %f\n",periode);
|
||||
printf("temps : %f\n",temps);*/
|
||||
|
||||
//Fill array with the power of the signal for each captor
|
||||
for(int i = 1; i < nCol; i++){
|
||||
|
@ -27,7 +28,5 @@ int main(int argc , char** argv){
|
|||
//printArray(p,nRow,nCol);
|
||||
double pw[8];
|
||||
power(p,pw);
|
||||
for(int i = 1 ; i < nCol ; i++){
|
||||
printf("power c°%d : %f\n",i,pw[i]);
|
||||
}
|
||||
writePowerData(pw,8);
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
#include <math.h>
|
||||
|
||||
void *power(int **p, double a[]);
|
||||
void power(int **p, double a[]);
|
800011
Code-C/rawData.txt
800011
Code-C/rawData.txt
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue