« 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 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",
fclose(fp);
printf(" Dans gnuplot -> plot \"%s\" \n\n"
" 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.
▲ 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;
/* --*/
fprintf(fp," %6.3f %6.3f\n", a, f(a));▼
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;
"
"
" plot \"%s\",\\\n"\▼
" %s\n"\▼
" reset",datafile,feq);▼
fclose(fp);
printf("\n\n load \"a_main.plt\" with gnuplot."
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));
if
fprintf(fp,"# Fichier de commande pour Gnuplot \n"
▲ " reset",datafile,feq);
fclose(fp);
▲ if (!(fp = fopen("a_main.plt","w")))
▲ fprintf(fp,"# Fichier de commande pour Gnuplot \n"\
▲ "# En ligne de commande : load \"a_main.plt\"\n"\
▲ " set zeroaxis\n"\
▲ fclose(fp);
return 0;
}
/* ------------------------------ */
int main(void)
Ligne 322 ⟶ 282 :
G_plot();
printf("\n\n load \"a_main.plt\" with gnuplot.
getchar();
Ligne 330 ⟶ 289 :
}
</source>
|