1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include<complex.h>
typedef struct complexe complexe;
struct complexe
{
double reel;
complex im;
};
void fourier (double** tab, complexe** tabk, double pointsespace, double a,double h,double delta)//fonction transformée de fourrier
{
int e=0;//déclaration des variables nécessaires
double f=0,X=0,z=0;
double k2=0;
int d=0;
double somme1=0;
double somme2=0;
/*********************************************************************************/
FILE* reel = NULL;
FILE* ima = NULL;
FILE* k = NULL;
FILE* i = NULL;
FILE* result = NULL;
reel = fopen("reel.xls","w+");
ima = fopen("ima.xls","w+");
k = fopen("k.xls","w+");
result = fopen("resultats/resultats.xls","w+");
fprintf (result,"k\tpartie reelle\tpartie imaginaire:\n");
/*********************************************************************************/
for (k2=-pointsespace/2; k2 < (pointsespace/2)-1; k2++)//on calcul ici la partie réelle de la TF
{
for (e=0; e < pointsespace; e++)
{
X=a+k2*h;
somme1+=(1/pointsespace)*(tab[e][d]*cos(2*3.1415*X*e/pointsespace));
somme2+=(1/pointsespace)*(tab[e][d]*sin(2*3.1415*X*e/pointsespace));
}
z=k2+pointsespace/2;
tabk[z][d]=somme1;
tabk[z][d].im=somme2;
printf ("resultat fourier reel:\n");
printf ("%lf\n", tabk[k2][d].reel);
fprintf(reel, " %lf\n",tabk[k2][d].reel);
fprintf(k, " k= %ld\n ",k2);
printf ("resultat fourier imaginaire:\n");
printf ("%lf\n", tabk[k2][d].im);
fprintf(ima, " %lf\n",tabk[k2][d].im);
e=k2+1;
fprintf (result,"%ld\t%lf\t%lf\n", e, tabk[k2][d].reel, tabk[k2][d].im);
}
fclose(reel);
fclose(ima);
fclose(k);
fclose(result);
}; |
Partager