« Mathc gnuplot/Fichiers pour gnuplot » : différence entre les versions

Contenu supprimé Contenu ajouté
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 44 :
#include <stdio.h>
#include <math.h>
/* ------------------------------ */
 
/* ------------------------------ */
double f(double x){return(pow(x,2.));}
/* ------------------------------ */
 
int main(void)
{
FILE *fp; /* Déclarer un pointeur de fichier. */
double a;
 
fp = fopen("list.txt","w"); /* Ouvrir le fichier en mode écriture. */
/* fp est un pointeur de fichier */
/* qui pointe sur "list.txt" */
 
for(a = -5.0; a <= 5.0; a++)
 
fprintf(fp," %6.3f %6.3f\n", /* Imprimer dans le fichier */
a, f(a));
 
fclose(fp); /* Fermer le fichier */
 
printf("\n\n Ouvrir le fichier list.txt "
 
printf( "\n\n OuvrirPress lereturn fichierto listcontinue.txt\n ");
 
printf("\n\n Press return to continue.\n");
getchar();
 
Ligne 75 ⟶ 67 :
}
</source>
 
 
 
Ligne 94 ⟶ 85 :
#include <stdio.h>
#include <math.h>
/* ------------------------------ */
 
/* ------------------------------ */
double f(double x){return(pow(x,2.));}
/* ------------------------------ */
 
 
int main(void)
{
Ligne 107 ⟶ 94 :
FILE *fp = fopen(datafile,"w");
 
if (fp==NULL) return 0;
 
for(a = -5.0; a <= 5.0; a+=.2)
fprintf(fp," %6.3f %6.3f\n", a, f(a));
a, f(a));
fclose(fp);
 
printf(" Dans gnuplot -> plot \"%s\" \n\n",datafile);
" Press return to continue. \n\n",datafile);
 
printf("\n\n Press return to continue.\n");
getchar();
 
Ligne 140 ⟶ 127 :
#include <stdio.h>
#include <math.h>
/* ------------------------------ */
 
/* ------------------------------ */
char heq[] = "sin(x)";
char geq[] = "cos(x)";
/* ------------------------------ */
 
 
int main(void)
{
Ligne 154 ⟶ 137 :
if (fp == NULL) return 0;
 
fprintf(fp,"# Fichier de commande pour Gnuplot \n"\
"# En ligne de commande : load \"a_main.plt\"\n"\
"#\n\n"\
" set zeroaxis\n"\
" plot %s,\\\n"\
" %s \n\n"\
" reset", geq, heq);
fclose(fp);
 
printf("\n\n load \"a_main.plt\" with gnuplot.\n");
printf( "\n\n Press return to continue.\n ");
 
printf("\n\n Press return to continue.\n");
getchar();
 
Ligne 205 ⟶ 187 :
#include <stdio.h>
#include <math.h>
/* ------------------------------ */
 
/* ------------------------------ */
double f(double x){return(cos(x));}
char feq[] = "cos(x)";
/* ------------------------------ */
 
 
int main(void)
{
char datafile[]="data";
FILE *fp;
char datafile[]="data";
double a;
/* --*/
 
if (!(fp = fopen("a_main.plt"datafile,"w"))) return 0;
 
if for(!(fpa = fopen(datafile,"w"))-5.0; a <= 5.0; a+=.2)
fprintf(fp," %6.3f %6.3f\n", a, f(a));
return 0;
for(a = -5.0; a <= 5.0; a+=.2)
fprintf(fp," %6.3f %6.3f\n", a, f(a));
fclose(fp);
/* --*/
 
if (!(fp = fopen("a_main.plt","w"))) return 0;
 
fprintf(fp,"# Fichier de commande pour Gnuplot \n"\
 
if (!(fp = fopen( "# En ligne de commande : load \"a_main.plt\","w\n")))
return 0; "#\n\n"
fprintf(fp,"# Fichier de commande pour Gnuplot " set zeroaxis\n"\
"# En ligne de commande : loadplot \"a_main.plt%s\",\\\n"\
"#\n %s\n"\
" set" zeroaxis\nreset"\,datafile,feq);
" plot \"%s\",\\\n"\
" %s\n"\
" reset",datafile,feq);
fclose(fp);
 
printf("\n\n load \"a_main.plt\" with gnuplot."
 
printf( "\n\n loadPress \"a_main.plt\"return withto gnuplotcontinue.\n ");
 
printf("\n\n Press return to continue.\n");
getchar();
 
Ligne 278 ⟶ 249 :
#include <stdio.h>
#include <math.h>
/* ------------------------------ */
 
/* ------------------------------ */
double f(double x){return(cos(x));}
char feq[] = "cos(x)";
/* ------------------------------ */
 
/* ------------------------------ */
int G_plot(void)
{
char datafile[]="data";
FILE *fp;
char datafile[]="data";
double a;
 
if(!(fp = fopen(datafile,"w"))) return 0;
for(a = -5.0; a <= 5.0; a+=.2)
fprintf(fp," %6.3f %6.3f\n", a, f(a));
fclose(fp);
 
if (!(fp = fopen(datafile"a_main.plt","w"))) return 0;
fprintf(fp,"# Fichier de commande pour Gnuplot \n"
return 0;
"# En ligne de commande : load \"a_main.plt\"\n"\
for(a = -5.0; a <= 5.0; a+=.2)
fprintf(fp," %6.3f %6.3f\n", a, f(a));"#\n\n"
" set zeroaxis\n"\
" plot \"%s\",\\\n"\
" %s\n"\
" reset",datafile,feq);
fclose(fp);
 
 
 
if (!(fp = fopen("a_main.plt","w")))
return 0;
fprintf(fp,"# Fichier de commande pour Gnuplot \n"\
"# En ligne de commande : load \"a_main.plt\"\n"\
"#\n\n"\
" set zeroaxis\n"\
" plot \"%s\",\\\n"\
" %s\n"\
" reset",datafile,feq);
fclose(fp);
 
return 0;
}
/* ------------------------------ */
 
/* ------------------------------ */
int main(void)
Ligne 322 ⟶ 282 :
G_plot();
 
printf("\n\n load \"a_main.plt\" with gnuplot.\n");
printf( "\n\n Press return to continue.\n ");
 
printf("\n\n Press return to continue.\n");
getchar();
 
Ligne 330 ⟶ 289 :
}
</source>