ftp.nice.ch/pub/next/unix/developer/plplot.3.0.s.tar.gz#/plplot/examples/example04.c

This is example04.c in view mode; [Download] [Up]

/* Illustration of logarithmic axes, and redefinition of window */
#include <math.h>

main()
{
  int i;
  static FLOAT freql[101],ampl[101],phase[101];
  double f0, freq;

  plstar(1,1);
  pladv(0);
  plfont(2);

  f0 = 1000.0;
  for (i=0; i<=100; i++) {
    freql[i]=1.0+i/20.0;
    freq= pow(10.0,freql[i]);
    ampl[i]=20.0*log10(1.0/sqrt(1.0+pow((freq/f0),2.)));
    phase[i] = -(180.0/3.141592654)*atan(freq/f0);
  }

  plvpor(0.15,0.85,0.1,0.9);
  plwind(1.0,6.0,-80.0,0.0);
  plcol(1);
  plbox("bclnst",0.0,0,"bnstv",0.0,0);
  plcol(2);
  plline(101,freql,ampl);
  plcol(1);
  plptex(5.0,-30.0,1.0,-20.0,0.5,"-20 dB/decade");
  plwind(1.0,6.0,-100.0,0.0);
  plbox("",0.0,0,"cmstv",30.0,3);
  plcol(3);
  plline(101,freql,phase);

  plcol(1);
  plmtex("b",3.2,0.5,0.5,"Frequency");
  plmtex("t",2.0,0.5,0.5,"Single Pole Low-Pass Filter");
  plcol(2);
  plmtex("l",5.0,0.5,0.5,"Amplitude (dB)");
  plcol(3);
  plmtex("r",5.0,0.5,0.5,"Phase shift (degrees)");

  plend();
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.