{"action":"closed","issue":{"url":"https://api.github.com/repos/python-control/python-control/issues/58","labels_url":"https://api.github.com/repos/python-control/python-control/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/python-control/python-control/issues/58/comments","events_url":"https://api.github.com/repos/python-control/python-control/issues/58/events","html_url":"https://github.com/python-control/python-control/issues/58","id":68918831,"number":58,"title":"Fix for bug in margin.py","user":{"login":"callawaycass","id":11978339,"avatar_url":"https://avatars.githubusercontent.com/u/11978339?v=3","gravatar_id":"","url":"https://api.github.com/users/callawaycass","html_url":"https://github.com/callawaycass","followers_url":"https://api.github.com/users/callawaycass/followers","following_url":"https://api.github.com/users/callawaycass/following{/other_user}","gists_url":"https://api.github.com/users/callawaycass/gists{/gist_id}","starred_url":"https://api.github.com/users/callawaycass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/callawaycass/subscriptions","organizations_url":"https://api.github.com/users/callawaycass/orgs","repos_url":"https://api.github.com/users/callawaycass/repos","events_url":"https://api.github.com/users/callawaycass/events{/privacy}","received_events_url":"https://api.github.com/users/callawaycass/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/python-control/python-control/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-16T13:01:13Z","updated_at":"2015-04-18T16:47:54Z","closed_at":"2015-04-18T16:47:54Z","body":"Calling margin() or stability_margins() with (mag, phase, omega) form yields incorrect result. I found that the issue is in line 125 of margin.py, where it calls frdata.FRD to create the system:\r\n\r\n    sys = frdata.FRD(mag*np.exp((1j/360.)*phase), omega, smooth=True)\r\n\r\nThe phase angle conversion is incorrect. Changing this line to:\r\n\r\n    sys = frdata.FRD(mag*np.exp(1j*phase*np.pi/180), omega, smooth=True)\r\n\r\nyields the correct result. Also, it may be good to clearly indicate that the magnitude data in this form must be absolute magnitude, not dB, and that the phase must be in degrees. The frequency can be either Hz or rad/s... the output frequency is in the same units as whatever you put in (Matlab's documentation has a similar note)."}}