home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 344b.lha / plplot_v2.6 / examples / example04.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-27  |  997 b   |  47 lines

  1. /* Illustration of logarithmic axes, and redefinition of window */
  2.  
  3. #include "plplot.h"
  4. #include <math.h>
  5.  
  6. main()
  7. {
  8.   int i;
  9.   static PLFLT freql[101],ampl[101],phase[101];
  10.   PLFLT f0, freq;
  11.  
  12.   plstar(1,1);
  13.   pladv(0);
  14.   plfont(2);
  15.  
  16.   f0 = 1000.0;
  17.   for (i=0; i<=100; i++) {
  18.     freql[i]=1.0+i/20.0;
  19.     freq= pow(10.0,freql[i]);
  20.     ampl[i]=20.0*log10(1.0/sqrt(1.0+pow((freq/f0),2.)));
  21.     phase[i]=-(180.0/3.141592654)*atan(freq/f0);
  22.   }
  23.  
  24.   plvpor(0.15,0.85,0.1,0.9);
  25.   plwind(1.0,6.0,-80.0,0.0);
  26.   plcol(1);
  27.   plbox("bclnst",0.0,0,"bnstv",0.0,0);
  28.   plcol(2);
  29.   plline(101,freql,ampl);
  30.   plcol(1);
  31.   plptex(5.0,-30.0,1.0,-20.0,0.5,"-20 dB/decade");
  32.   plwind(1.0,6.0,-100.0,0.0);
  33.   plbox(" ",0.0,0,"cmstv",30.0,3);
  34.   plcol(3);
  35.   plline(101,freql,phase);
  36.  
  37.   plcol(1);
  38.   plmtex("b",3.2,0.5,0.5,"Frequency");
  39.   plmtex("t",2.0,0.5,0.5,"Single Pole Low-Pass Filter");
  40.   plcol(2);
  41.   plmtex("l",5.0,0.5,0.5,"Amplitude (dB)");
  42.   plcol(3);
  43.   plmtex("r",5.0,0.5,0.5,"Phase shift (degrees)");
  44.  
  45.   plend();
  46. }
  47.