{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "Vo4mY-6N2yoA" }, "source": [ "# 2章 動的システムの表現" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "id": "gJYRxJfd2yoC" }, "outputs": [], "source": [ "from control.matlab import *\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "\n", "#plt.rcParams['font.family'] ='sans-serif' #使用するフォント\n", "plt.rcParams['font.family'] = 'Times New Roman' # font familyの設定\n", "plt.rcParams['mathtext.fontset'] = 'cm' # math fontの設定\n", "plt.rcParams['xtick.direction'] = 'in' #x軸の目盛線が内向き('in')か外向き('out')か双方向か('inout')\n", "plt.rcParams['ytick.direction'] = 'in' #y軸の目盛線が内向き('in')か外向き('out')か双方向か('inout')\n", "plt.rcParams['xtick.major.width'] = 1.0 #x軸主目盛り線の線幅\n", "plt.rcParams['ytick.major.width'] = 1.0 #y軸主目盛り線の線幅\n", "plt.rcParams['font.size'] = 11 #フォントの大きさ\n", "plt.rcParams['axes.linewidth'] = 0.5 # 軸の線幅edge linewidth。囲みの太さ\n", "plt.rcParams['mathtext.default'] = 'it'#'regular'\n", "plt.rcParams['axes.xmargin'] = '0'\n", "plt.rcParams['axes.ymargin'] = '0.05'\n", "plt.rcParams['savefig.facecolor'] = 'None'\n", "plt.rcParams['savefig.edgecolor'] = 'None'\n", "\n", "plt.rcParams[\"legend.fancybox\"] = True # 丸角\n", "# plt.rcParams[\"legend.framealpha\"] = 1 # 透明度の指定、0で塗りつぶしなし\n", "# plt.rcParams[\"legend.edgecolor\"] = 'gray' # edgeの色を変更\n", "plt.rcParams[\"legend.handlelength\"] = 1.8 # 凡例の線の長さを調節\n", "plt.rcParams[\"legend.labelspacing\"] = 0.4 # 垂直方向(縦)の距離の各凡例の距離\n", "plt.rcParams[\"legend.handletextpad\"] = 0.7 # 凡例の線と文字の距離の長さ\n", "plt.rcParams[\"legend.markerscale\"] = 1.0 # 点がある場合のmarker scale" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "id": "iOA70Kcj2yoE" }, "outputs": [], "source": [ "def linestyle_generator():\n", " linestyle = ['-', '--', '-.', ':']\n", " lineID = 0\n", " while True:\n", " yield linestyle[lineID]\n", " lineID = (lineID + 1) % len(linestyle)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "id": "EEUYxua92yoE" }, "outputs": [], "source": [ "def plot_set(fig_ax, *args):\n", " fig_ax.set_xlabel(args[0])\n", " fig_ax.set_ylabel(args[1])\n", " fig_ax.grid(ls=':', lw=0.5)\n", " if len(args)==3:\n", " fig_ax.legend(loc=args[2])" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "id": "FomeQ5aF2yoE" }, "outputs": [], "source": [ "def bodeplot_set(fig_ax, *args):\n", " fig_ax[0].grid(which=\"both\", ls=':', lw=0.5)\n", " fig_ax[0].set_ylabel('Gain [dB]')\n", "\n", " fig_ax[1].grid(which=\"both\", ls=':', lw=0.5)\n", " fig_ax[1].set_xlabel('$\\omega$ [rad/s]')\n", " fig_ax[1].set_ylabel('Phase [deg]')\n", " \n", " if len(args) > 0:\n", " fig_ax[1].legend(loc=args[0])\n", " if len(args) > 1:\n", " fig_ax[0].legend(loc=args[1])" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# 図の保存パス\n", "figpath=\"./notebook_output/\"" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "# 数式処理のためにsympyをインポート\n", "import sympy as sp\n", "from sympy.matrices import *" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2.3.3 状態空間表現と伝達関数表現の相互変換" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### 例その1 ($m