Parametric Functions (C Code)

Smith Chart

#include <stdio.h>
#include "dislin.h"

#define N 1000
#define M 1000

int main ()
{ int i;
  float zimg[11] = {5.0, 2.0, 1.0, 0.5, 0.2, 0.0, -0.2, -0.5, -1.0, 
                    -2.0, -5.0};
  float zre[5] = {0.2, 0.5, 1.0, 2.0, 5.0};
  float x[N], y[N];
  float x2[5] = {0.42, 0.3, 0.63, 0.83, 0.67}, 
        y2[5] = {-0.11, 0.15, 0.28, 0.0, -0.43};
  float step;

  step = (50.0 + 50.0) / (N - 1);

  for (i = 0; i < N; i++)
  { x[i] = 0.5;
    y[i] = - 50.0 + i * step;
  }

  scrmod ("revers");
  metafl ("cons");
  disini ();
  pagera ();
  hwfont ();

  titlin ("Smith Chart", 1);
  name ("X-axis", "x");
  labtyp ("vert", "y");
  labtyp ("hori", "x");
  labdis (-50, "y");

  height (30);
  hname (30);
  ticpos ("revers", "y");
  grafr (zre, 5, zimg, 11);

  htitle (40);
  title ();

  gridre (1.0, -50.0, 50.0, M);
  gridre (2.0, -50.0, 50.0, M);
  gridre (3.0, -50.0, 50.0, M);
  gridre (4.0, -50.0, 50.0, M); 
  gridre (5.0, -50.0, 50.0, M);
  gridim (0.5, 0.001, 50.0, M);
  gridim (1.0, 0.001,  1.0, M);
  gridim (2.0, 0.001, 50.0, M);
  gridim (3.0, 0.001, 50.0, M);
  gridim (4.0, 0.001, 50.0, M);
  gridim (5.0, 0.001, 50.0, M);

  labdis (20, "y");
  ticpos ("labels", "y");
  labdig (-1, "y");
  ticks (10, "y");
  ypolar (180.0, -180.0, 180.0, -30.0, "Y-axis", 0);

  color ("red");
  curve  (x, y, N);

  polcrv("pspline");
  incmrk (1);
  color ("green");
  curve (x2, y2, 5); 
  disfin ();
}

Smith Chart, Admittance Plot

#include <stdio.h>
#include "dislin.h"
#define M 1000
 
int main ()
{ int i;
  float zimg[11] = {5.0, 2.0, 1.0, 0.5, 0.2, 0.0, -0.2, -0.5, -1.0, 
                    -2.0, -5.0};
  float zre[5] = {0.2, 0.5, 1.0, 2.0, 5.0};
  float x2[5] = {0.42, 0.3, 0.63, 0.83, 0.67}, 
        y2[5] = {-0.11, 0.15, 0.28, 0.0, -0.43};
  float x3[5], y3[5], v;


  // Convert impedance data to admittance by Y = 1 / Z
  for (i = 0; i < 5; i++)
  { v = x2[i] * x2[i] + y2[i] * y2[i];
    x3[i] = x2[i] / v;  
    y3[i] = -y2[i] / v;  
  }
 
  scrmod ("revers");
  metafl ("cons");
  disini ();
  pagera ();
  hwfont ();

  titlin ("Smith Chart", 1);
  titlin ("Admittance Plot", 2);

  axstyp ("admittance");
  name   ("X-axis", "x");
  name   ("Y-axis", "y");
  labtyp ("vert", "y");
  labtyp ("hori", "x");

  height (30);
  hname (30);
  color ("red");
  grafr (zre, 5, zimg, 11);

  gridre (1.0, -50.0, 50.0, M);
  gridre (2.0, -50.0, 50.0, M);
  gridre (3.0, -50.0, 50.0, M);
  gridre (4.0, -50.0, 50.0, M); 
  gridre (5.0, -50.0, 50.0, M);
  gridim (0.5, 0.001, 50.0, M);
  gridim (1.0, 0.001,  1.0, M);
  gridim (2.0, 0.001, 50.0, M);
  gridim (3.0, 0.001, 50.0, M);
  gridim (4.0, 0.001, 50.0, M);
  gridim (5.0, 0.001, 50.0, M);

  color ("fore");
  htitle (40);
  title ();

  polcrv("pspline");
  incmrk (1);
  color ("green");
  curve (x3, y3, 5); 
  disfin ();
}

Smith Chart, Impedance and Admittance Plot

#include <stdio.h>
#include "dislin.h"
#define M 1000

int main ()
{ int i;
  float zimg[11] = {5.0, 2.0, 1.0, 0.5, 0.2, 0.0, -0.2, -0.5, -1.0, 
                    -2.0, -5.0};
  float zre[5] = {0.2, 0.5, 1.0, 2.0, 5.0};
  float x2[5] = {0.42, 0.3, 0.63, 0.83, 0.67}, 
        y2[5] = {-0.11, 0.15, 0.28, 0.0, -0.43};
  float x3[5], y3[5], v;

  // Convert impedance data to admittance by Y = 1 / Z
  for (i = 0; i < 5; i++)
  { v = x2[i] * x2[i] + y2[i] * y2[i];
    x3[i] = x2[i] / v;  
    y3[i] = -y2[i] / v;  
  }

  scrmod ("revers");
  metafl ("cons");
  disini ();
  pagera ();
  hwfont ();

  titlin ("Smith Chart", 1);
  titlin ("Impedance and Admittance Plot", 2);

  labtyp ("vert", "y");
  labtyp ("hori", "x");
  labdis (-50, "y");
  labdis (10, "x");

  height (30);
  hname (30);
  ticpos ("reverse", "y");
  grafr (zre, 5, zimg, 11);

  htitle (40);
  title ();

  gridre (1.0, -50.0, 50.0, M);
  gridre (2.0, -50.0, 50.0, M);
  gridre (3.0, -50.0, 50.0, M);
  gridre (4.0, -50.0, 50.0, M); 
  gridre (5.0, -50.0, 50.0, M);
  gridim (0.5, 0.001, 50.0, M);
  gridim (1.0, 0.001,  1.0, M);
  gridim (2.0, 0.001, 50.0, M);
  gridim (3.0, 0.001, 50.0, M);
  gridim (4.0, 0.001, 50.0, M);
  gridim (5.0, 0.001, 50.0, M);

  incmrk (1);
  polcrv ("pspline");
  color ("green");
  curve (x2, y2, 5);
  endgrf ();

  axstyp ("admittance");
  labdis (20, "y");

  ticpos ("labels", "y");
  color ("red");
  ticpos ("reverse", "x");
  labdis (-50, "x");
  
  grafr (zre, 5, zimg, 11);

  gridre (1.0, -50.0, 50.0, M);
  gridre (2.0, -50.0, 50.0, M);
  gridre (3.0, -50.0, 50.0, M);
  gridre (4.0, -50.0, 50.0, M); 
  gridre (5.0, -50.0, 50.0, M);
  gridim (0.5, 0.001, 50.0, M);
  gridim (1.0, 0.001,  1.0, M);
  gridim (2.0, 0.001, 50.0, M);
  gridim (3.0, 0.001, 50.0, M);
  gridim (4.0, 0.001, 50.0, M);
  gridim (5.0, 0.001, 50.0, M);

  polcrv("pspline");
  color ("green");
  curve (x3, y3, 5);
 
  endgrf ();
  disfin ();
}