mirror of
https://github.com/gabrielkheisa/control-system.git
synced 2024-11-23 20:03:22 +07:00
Correct slight space
This commit is contained in:
parent
f2556fd7ba
commit
4a8b20b378
@ -1,32 +1,17 @@
|
||||
{
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"provenance": [],
|
||||
"collapsed_sections": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"name": "python3",
|
||||
"display_name": "Python 3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 132,
|
||||
"metadata": {
|
||||
"id": "aDtFkeqAvLX2"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Import Libraries\n",
|
||||
"import numpy as np\n",
|
||||
"import pandas as pd"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "aDtFkeqAvLX2"
|
||||
},
|
||||
"execution_count": 132,
|
||||
"outputs": []
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
@ -38,14 +23,17 @@
|
||||
"source": [
|
||||
"# Define RouthStability Class \n",
|
||||
"class RouthStability():\n",
|
||||
"\n",
|
||||
" ## constructor takes string of coefficiens from polynomial\n",
|
||||
" def __init__(self, den):\n",
|
||||
" self.den = np.array([float(item) for item in den.split()])\n",
|
||||
" self.deg = len(self.den)\n",
|
||||
"\n",
|
||||
" ## append k as constant in array\n",
|
||||
" def set_k(self, k):\n",
|
||||
" self.den = np.append(self.den, float(k))\n",
|
||||
" self.deg += 1\n",
|
||||
"\n",
|
||||
" ## generate routh table and print its state\n",
|
||||
" def calc_routh(self):\n",
|
||||
" height = (self.deg+1)//2\n",
|
||||
@ -67,18 +55,22 @@
|
||||
" print(\"SYSTEM IS STABLE\")\n",
|
||||
" else:\n",
|
||||
" print(\"SYSTEM IS UNSTABLE\")\n",
|
||||
"\n",
|
||||
" ## print generated route table\n",
|
||||
" def show_tab(self):\n",
|
||||
" print(self.df)\n",
|
||||
"\n",
|
||||
" ## return generated route DataFrame\n",
|
||||
" def get_table(self):\n",
|
||||
" return self.df\n",
|
||||
"\n",
|
||||
" ## return system stability as boolean\n",
|
||||
" def is_stable(self):\n",
|
||||
" flag = True\n",
|
||||
" for item in self.df[0]:\n",
|
||||
" if item < 0: flag = False\n",
|
||||
" return flag\n",
|
||||
" \n",
|
||||
" ## return the value of a polynomial\n",
|
||||
" def get_poly(self, x):\n",
|
||||
" total = 0\n",
|
||||
@ -90,27 +82,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"# First Testing\n",
|
||||
"den = input(\"Enter your polynomial: \")\n",
|
||||
"k_in = input(\"Enter your K: \")\n",
|
||||
"\n",
|
||||
"rs = RouthStability(den)\n",
|
||||
"rs.set_k(k_in)\n",
|
||||
"rs.calc_routh()"
|
||||
],
|
||||
"execution_count": 134,
|
||||
"metadata": {
|
||||
"id": "Je19fGrvtOu4",
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "Je19fGrvtOu4",
|
||||
"outputId": "c99b1159-f745-4c3f-c012-c2f464b8edb0"
|
||||
},
|
||||
"execution_count": 134,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter your polynomial: 1 2 3 4 5\n",
|
||||
"Enter your K: 6\n",
|
||||
@ -123,19 +106,20 @@
|
||||
"SYSTEM IS UNSTABLE\n"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
],
|
||||
"source": [
|
||||
"# Second Testing\n",
|
||||
"# First Testing\n",
|
||||
"den = input(\"Enter your polynomial: \")\n",
|
||||
"k_in = input(\"Enter your K: \")\n",
|
||||
"\n",
|
||||
"rs = RouthStability(den)\n",
|
||||
"rs.set_k(k_in)\n",
|
||||
"rs.calc_routh()"
|
||||
],
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 136,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
@ -143,11 +127,10 @@
|
||||
"id": "kFgcxNcscafI",
|
||||
"outputId": "25aadcc4-6a29-4c16-c992-46d95a56cbfb"
|
||||
},
|
||||
"execution_count": 136,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter your polynomial: 12 56 37 80\n",
|
||||
"Enter your K: 17\n",
|
||||
@ -160,19 +143,20 @@
|
||||
"SYSTEM IS STABLE\n"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
],
|
||||
"source": [
|
||||
"# Third Testing\n",
|
||||
"# Second Testing\n",
|
||||
"den = input(\"Enter your polynomial: \")\n",
|
||||
"k_in = input(\"Enter your K: \")\n",
|
||||
"\n",
|
||||
"rs = RouthStability(den)\n",
|
||||
"rs.set_k(k_in)\n",
|
||||
"rs.calc_routh()"
|
||||
],
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 137,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
@ -180,11 +164,10 @@
|
||||
"id": "jaif_A4_hfeJ",
|
||||
"outputId": "0b387e7e-efbf-4f5c-fb45-d98489bbba3e"
|
||||
},
|
||||
"execution_count": 137,
|
||||
"outputs": [
|
||||
{
|
||||
"output_type": "stream",
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Enter your polynomial: 1.2 6.81 7.31\n",
|
||||
"Enter your K: 3.141\n",
|
||||
@ -196,16 +179,31 @@
|
||||
"SYSTEM IS STABLE\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Third Testing\n",
|
||||
"den = input(\"Enter your polynomial: \")\n",
|
||||
"k_in = input(\"Enter your K: \")\n",
|
||||
"\n",
|
||||
"rs = RouthStability(den)\n",
|
||||
"rs.set_k(k_in)\n",
|
||||
"rs.calc_routh()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"source": [],
|
||||
"metadata": {
|
||||
"id": "SjkQCR9chk6P"
|
||||
},
|
||||
"execution_count": null,
|
||||
"outputs": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"collapsed_sections": [],
|
||||
"provenance": []
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user