Title: Different results in Matlab and Python for StateSystem · python-control/python-control · Discussion #1077 · GitHub
Open Graph Title: Different results in Matlab and Python for StateSystem · python-control/python-control · Discussion #1077
X Title: Different results in Matlab and Python for StateSystem · python-control/python-control · Discussion #1077
Description: Different results in Matlab and Python for StateSystem
Open Graph Description: While migrating to Python from Matlab, I get different result for StateSystem transform. In Matlab,there is a 2 in 2 out system: tf1 = -4 -------------------------------- 1e06 s^3 + 30000 s^2 + 300...
X Description: While migrating to Python from Matlab, I get different result for StateSystem transform. In Matlab,there is a 2 in 2 out system: tf1 = -4 -------------------------------- 1e06 s^3 + 30000 s^2 + 300...
Opengraph URL: https://github.com/python-control/python-control/discussions/1077
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Different results in Matlab and Python for StateSystem","text":"While migrating to Python from Matlab, I get different result for StateSystem transform.
\nIn Matlab,there is a 2 in 2 out system:
\ntf1 =
\n -4\n --------------------------------\n 1e06 s^3 + 30000 s^2 + 300 s + 1 \n
\nNumerator: {[0 0 0 -4]}
\nDenominator: {[1000000 30000 300 1]}
\ntf2 =
\n0\n
\nNumerator: {[0 0 0]}
\nDenominator: {[5600 150 1]}
\ntf3 =
\n 0.75\n --------------------\n 5600 s^2 + 150 s + 1\n
\nNumerator: {[0 0 0.7500]}
\nDenominator: {[5600 150 1]}
\nMatlabCode:
\nsys=[tf1,tf2;tf3,0];\nsys_ss=ss(sys);
\nthe output is:
\nsys_ss =\n \n A = \n x1 x2 x3 x4 x5\n x1 -0.03 -0.0192 -0.008192 0 0\n x2 0.01562 0 0 0 0\n x3 0 0.007812 0 0 0\n x4 0 0 0 -0.02679 -0.01143\n x5 0 0 0 0.01562 0\n \n B = \n u1 u2\n x1 0.25 0\n x2 0 0\n x3 0 0\n x4 0.125 0\n x5 0 0\n \n C = \n x1 x2 x3 x4 x5\n y1 0 0 -0.1311 0 0\n y2 0 0 0 0 0.06857\n \n D = \n u1 u2\n y1 0 0\n y2 0 0\n
\nIn Python,I use control.ss:
\nimport control\n\nnum11 = [0,0,0,-4]\nnum12 = [0,0,0]\nnum21 = [0,0,0.7500]\nnum22 = [0]\n\nrow1 = [num11, num12]\nrow2 = [num21, num22]\nnumerator = [row1, row2]\ndenominator = [\n [[1000000, 30000, 300,1], [5600,150,1]],\n [[5600,150,1], [1]]\n ]\nG = control.tf(numerator,\n denominator)\ncontrol.ss(G )
\nThen I got different StateSpace,
\n
\nWhat am I missing here? How can I fix to get the exact same results?
","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"A little problem is given by the very little values in the state matrix (...*e-17): I also found that python control doesn't approximate these values to \"0\".
","upvoteCount":1,"url":"https://github.com/python-control/python-control/discussions/1077#discussioncomment-11486012"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:4ad2cd42-577d-4894-0389-fb60bc8f5b0e |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | CD16:2333C8:14D755D:1C1E6B8:697978A4 |
| html-safe-nonce | b11c1766a6621b0b326bcf1bc9c5f9eb711bb89dfafad3e95a7f4bb7872e8bbf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDE2OjIzMzNDODoxNEQ3NTVEOjFDMUU2Qjg6Njk3OTc4QTQiLCJ2aXNpdG9yX2lkIjoiMzg1NzQwMDc0NTUyNzE3OTQyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | de6d987581b96ce3b62350fad44cb85c6343f921537b53bb9a0615c359c548e5 |
| hovercard-subject-tag | discussion:7623339 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/python-control/python-control/1077/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/3abc1ea948d76398bf329ca3ecded98c8914a8f60cea6335a7f16d4a0885b7d2/python-control/python-control/discussions/1077 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3abc1ea948d76398bf329ca3ecded98c8914a8f60cea6335a7f16d4a0885b7d2/python-control/python-control/discussions/1077 |
| og:image:alt | While migrating to Python from Matlab, I get different result for StateSystem transform. In Matlab,there is a 2 in 2 out system: tf1 = -4 -------------------------------- 1e06 s^3 + 30000 s^2 + 300... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | c049b65ec7e54cbf2521f5a560b6527714c612b0bd169188e2ea6e16f83bd5f4 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-control/python-control git https://github.com/python-control/python-control.git |
| octolytics-dimension-user_id | 2285872 |
| octolytics-dimension-user_login | python-control |
| octolytics-dimension-repository_id | 22791752 |
| octolytics-dimension-repository_nwo | python-control/python-control |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 22791752 |
| octolytics-dimension-repository_network_root_nwo | python-control/python-control |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 87b137883e35e2766c3d0f6a257c4044f6390b83 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width