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 * @author koga
20 * @version $Revision: 1.15 $, 2004/05/01
21 */
22 public class Semilogx {
23
24 /**
25 * メインメソッド
26 *
27 * @param args コマンドライン引数
28 * @throws InterruptedException 強制終了された場合
29 */
30 public static void main(String[] args) throws InterruptedException {
31 Polynomial s = new Polynomial("s"); //$NON-NLS-1$
32 DoubleComplexNumber j = new DoubleComplexNumber(0, 1);
33 DoubleMatrix w = LogarithmicallySpacedVector.create(-2.0, 3.0);
34 RationalPolynomial G = s.add(1).inverse();
35 DoubleComplexMatrix Gjw = (DoubleComplexMatrix)G.evaluateElementWise(w.multiply(j));
36 DoubleMatrix g = ((DoubleMatrix)Gjw.absElementWise()).log10ElementWise().multiply(20);
37 DoubleMatrix p = ((DoubleMatrix)Gjw.argumentElementWise()).multiply(180 / Math.PI);
38 Mgplot.semilogx(1, w, g, new String[] {"gain"}); //$NON-NLS-1$
39 Mgplot.semilogx(2, w, p, new String[] {"phase"}); //$NON-NLS-1$
40 Thread.sleep(10000);
41 Mgplot.quit();
42 }
43 }
|