Aller au contenu

Mathc initiation/0003

Un livre de Wikilivres.


Sommaire


Installer ce fichier dans votre répertoire de travail.

kg_fab.h
/* --------------------------------- */
/* save as  kg_fab.h                 */
/* --------------------------------- */
void G_fab_2d(
CTRL_splot     w,
double         a,
double         b,
double      step,
double (*P_f)(double x)
)
{
FILE *fp = fopen("a_main.plt","w");

double i = a;

fprintf(fp," reset\n"
           " set zeroaxis lt 8\n"
           " set grid\n\n"
           " set size ratio -1\n"
           " plot [%0.3f:%0.3f] [%0.3f:%0.3f]\\\n"
           " \"a\"    with linesp lt 7 lw 3 pt 1,\\\n"
           " \"b\"    with linesp lt 7 lw 3 pt 1,\\\n"
           " \"fab\"  with line   lt 8 lw 3\n\n",
             w.xmin,w.xmax,w.ymin,w.ymax);
  fclose(fp);


  fp = fopen("a",  "w");
     fprintf(fp," %0.6f   %0.6f\n", a, (*P_f)(a));
     fprintf(fp," %0.6f   %0.6f\n", a, 0.0);
      fclose(fp);


  fp = fopen("b",  "w");
     fprintf(fp," %0.6f   %0.6f\n", b, (*P_f)(b));
     fprintf(fp," %0.6f   %0.6f\n", b, 0.0);
      fclose(fp);
               
                
  fp = fopen("fab",  "w");
  do{ 
	  fprintf(fp," %0.6f   %0.6f\n", i,(*P_f)(i));
      i += step;
    }while(i <= b+step);
 fclose(fp);
}
/* --------------------------------- */
/* --------------------------------- */