Semilogx.java
01 /*
02  * $Id: Semilogx.java,v 1.19 2008/02/02 05:53:03 koga Exp $
03  *
04  * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05  *
06  */
07 package matxbook.chap12;
08 
09 import java.io.IOException;
10 
11 import org.mklab.nfc.matrix.DoubleComplexMatrix;
12 import org.mklab.nfc.matrix.DoubleMatrix;
13 import org.mklab.nfc.matrix.misc.LogarithmicallySpacedVector;
14 import org.mklab.nfc.scalar.DoubleComplexNumber;
15 import org.mklab.nfc.scalar.Polynomial;
16 import org.mklab.nfc.scalar.RationalPolynomial;
17 import org.mklab.nfc.util.Pause;
18 import org.mklab.tool.graph.gnuplot.Canvas;
19 import org.mklab.tool.graph.gnuplot.Gnuplot;
20 
21 
22 /**
23  @author koga
24  @version $Revision: 1.19 $, 2004/05/01
25  */
26 public class Semilogx {
27 
28   /**
29    * メインメソッド
30    
31    @param args コマンドライン引数
32    @throws InterruptedException 強制終了された場合
33    @throws IOException キーボードから入力できない場合
34    */
35   @SuppressWarnings("nls")
36   public static void main(String[] argsthrows InterruptedException, IOException {
37     Polynomial s = new Polynomial("s");
38     DoubleComplexNumber j = new DoubleComplexNumber(01);
39     DoubleMatrix w = LogarithmicallySpacedVector.create(-2.03.0);
40     RationalPolynomial G = s.add(1).inverse();
41     DoubleComplexMatrix Gjw = (DoubleComplexMatrix)G.evaluateElementWise(w.multiply(j));
42     DoubleMatrix g = ((DoubleMatrix)Gjw.absElementWise()).log10ElementWise().multiply(20);
43     DoubleMatrix p = ((DoubleMatrix)Gjw.argumentElementWise()).multiply(180 / Math.PI);
44 
45     Gnuplot gnuplot1 = new Gnuplot();
46     Canvas canvas1 = gnuplot1.createCanvas();
47     canvas1.semilogx(w, g, new String[] {"gain"});
48 
49     Gnuplot gnuplot2 = new Gnuplot();
50     Canvas canvas2 = gnuplot2.createCanvas();
51     canvas2.semilogx(w, p, new String[] {"phase"});
52 
53     Pause.pause();
54     gnuplot1.close();
55     gnuplot2.close();
56   }
57 }