next up previous contents index
Next: MASTER Routine Examples Up: Programming Examples Previous: Lower Level Routines

C Language Programming Example

  The following is an illustration of how to use lower level LONGLIB routines to produce a plot from  VAX C.

/* Example in VAX C */

main 
{
  real x[100],y[100],dx,xmin,dy,ymin;
  real exp(),sin(),y0;
  int icol[4] = 1 , 2, 3, 4;
  int i,n1,n2;
  real pi = 3.141592654;
  real p = 112., u = 85., a = 25., b = .013, phi = .3;

  for (i = 1; i < 100 ; i++) {
    x[i] = i - 1;
    y[i] = sin( (i-1) * pi / a + phi) * exp(-i * b);
  }
  frame_(&3,&-3,&0.,&0.,&1.);          /* Initialize */
  scale_(x,&8.,&100,&1,&1,&xmin,&dx);
  scale_(y,&6.,&100,&1,&1,&ymin,&dy);
  y0 = -ymin / dy;
  plot_(&2.,&2.,&-3);                  /* new origin */
  axis_(&0.,&y0,"X-AXIS",&-6-100000,&20.,&0.,&xmin,&dx,&n1,&n2,icol);
  axis_(&0.,&0.,"SINE",&4+100000,&17.,&90.&ymin,&dy,&n1,&n2,icol);
  plot_(&4.,&0.,&0);                   /* new color */
  line_(x,y,&100,&1,&5,&2,&1,&1,&xmin,&dx,&ymin,&dy);
  plot_(&0.,3&0.,&3)                   /* pen up */
  cterm_(&2);                          /* ask if screen clear */
  plotnd_();                           /* terminate plotting */

}



David Long
Wed Jun 12 10:34:11 MDT 1996