youyoumse
Messages postés2Date d'inscriptionmardi 20 mai 2003StatutMembreDernière intervention20 mai 2003
-
20 mai 2003 à 15:23
muzamfr
Messages postés4Date d'inscriptiondimanche 14 mars 2004StatutMembreDernière intervention24 mars 2005
-
9 juin 2005 à 19:32
:-p
bonjour a tous je voudrais un coup de main pour un projet informatique d' ecole d ingenieur!
l' algorithme de la transformée de fourier(systeme de fourier) en langage c!!!!
merci d avance
muzamfr
Messages postés4Date d'inscriptiondimanche 14 mars 2004StatutMembreDernière intervention24 mars 2005 9 juin 2005 à 19:31
/* *************************** TFD ****************************
CETTE FONCTION REMPLI LA VARIABLE POINTEE PAR SIGNAL (UN TABLEAU)
PAR LE RESULTAT DE LA TRANSFORMEE DE FOURIER DISCRETE */
#define pi 3.141592654
void TFD(float *signal,int N,float pas){
/* DECLARATION DES VARIABLES */
char nomfichier[]="TFD.dat";
int i,j,x=0,u;
float *S;
float *y;
float *z;
FILE *f2;
/* ALLOCATION DE LA MEMOIRE */
if((S=(float *)calloc(N,sizeof(float)))!=NULL);
else{
printf("Erreur d'allocation de la mémoire");
exit(0);
}
if((y=(float *)calloc(N,sizeof(float)))!=NULL);
else{
printf("Erreur d'allocation de la mémoire");
exit(0);
}
if((z=(float *)calloc(N,sizeof(float)))!=NULL);
else{
printf("Erreur d'allocation de la mémoire");
exit(0);
}
/* CREATION ET OUVERTURE DU FICHIER EN MODE ECRITURE */
f2=fopen(nomfichier, "w+");
fmanip(f2,nomfichier); /* fmanip TEST LA BONNE OUVERTURE DU FICHIER */
/* CALCULE DE LA TFD */
for (i=0;i<N;i++){
y[i]=0; /* PARTIE REELLE */
z[i]=0; /* PARTIE IMAGINAIRE */
for(j=0;j<N;j++){
y[i]=signal[j]*cos(j*i*pi/N)+y[i];
z[i]=signal[j]*sin(j*i*pi/N)+z[i];
}
S[i]=sqrt((y[i]*y[i])+(z[i]*z[i])); /* RESULTAT DE LA TFD */
}
/* REMPLISSAGE DU FICHIER "TFD.dat" */
for (i=0;i<2*N;i++){
if(i<N){
fprintf(f2,"%f\t\t%f\t\n",(i/(pas*N))/2,S[i]*pas);}
/* SYMETRIE DES RESULTATS DE LA TFD ET PLACEMENT DANS FICHIERS */
else{
u=i-x;
fprintf(f2,"%f\t\t%f\t\n",(i/(pas*N))/2,S[u]*pas);
x=(x+2);}
}