01 /*
02 * $Id: Semilogx.java,v 1.15 2008/02/02 05:53:03 koga Exp $
03 *
04 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05 *
06 */
07 package matxbook.chap12old;
08
09 import org.mklab.nfc.matrix.DoubleComplexMatrix;
10 import org.mklab.nfc.matrix.DoubleMatrix;
11 import org.mklab.nfc.matrix.misc.LogarithmicallySpacedVector;
12 import org.mklab.nfc.scalar.DoubleComplexNumber;
13 import org.mklab.nfc.scalar.Polynomial;
14 import org.mklab.nfc.scalar.RationalPolynomial;
15 import org.mklab.tool.graph.mgplot.Mgplot;
16
17
18 /**
19 * 片対数グラフをのサンプルです。
20 * @author koga
21 * @version $Revision: 1.15 $, 2004/05/01
22 */
23 public class Semilogx {
24
25 /**
26 * メインメソッド
27 *
28 * @param args コマンドライン引数
29 * @throws InterruptedException 強制終了された場合
30 */
31 public static void main(String[] args) throws InterruptedException {
32 Polynomial s = new Polynomial("s"); //$NON-NLS-1$
33 DoubleComplexNumber j = new DoubleComplexNumber(0, 1);
34 DoubleMatrix w = LogarithmicallySpacedVector.create(-2.0, 3.0);
35 RationalPolynomial G = s.add(1).inverse();
36 DoubleComplexMatrix Gjw = (DoubleComplexMatrix)G.evaluateElementWise(w.multiply(j));
37 DoubleMatrix g = ((DoubleMatrix)Gjw.absElementWise()).log10ElementWise().multiply(20);
38 DoubleMatrix p = ((DoubleMatrix)Gjw.argumentElementWise()).multiply(180 / Math.PI);
39 Mgplot.semilogx(1, w, g, new String[] {"gain"}); //$NON-NLS-1$
40 Mgplot.semilogx(2, w, p, new String[] {"phase"}); //$NON-NLS-1$
41 Thread.sleep(10000);
42 Mgplot.quit();
43 }
44 }
|