Bode Plot Display All Stability Margins

조회 수: 218 (최근 30일)
Andrew Hunter
Andrew Hunter 2019년 11월 22일
답변: Erick Oberstar 2022년 4월 17일
Hi,
Is there a way to programmitically set "All Stability Margins" for a Bode plot from matlab script or command window? I don't want to have to set it everytime in the plot characteristics window.
-Andy
  댓글 수: 5
Andrew Hunter
Andrew Hunter 2019년 11월 23일
Ahh this is exactly what i was looking for! Thank you! This function characteristicmanager doesnt seem to be available anywhere on the matlab web documentation. Do you know where i can find a comprehensive documentation of the matlab “language” and built in functions?
Adam Danz
Adam Danz 2019년 11월 23일
편집: Adam Danz 2019년 11월 25일
Glad I could help (and learn a little, myself!). I added an answer below that contains several links to documentation. There's relatively little information available on some of these properties so I wouldn't spend more than 10 minutes searching the internet before rolling up your sleeves and just trying stuff. Feel free to share what you've learned - I'd be interested in hearing what worked for you.

댓글을 달려면 로그인하십시오.

답변 (3개)

Adam Danz
Adam Danz 2019년 11월 23일
편집: Adam Danz 2019년 12월 19일
Documentation on bode plots is a bit sparse but here's some ways to modify the plots programmatically.
Use getoptions() / setoption()
The handle output to h=bodeplot(sys) can be used to customize the plot by using the p=getoptions(h) to get the plot options handle and then setoptions(h,p) to apply the changed settings to the plot. See the setoptions link for an example.
Use the plot handle directly
The handle output to h=bodeplot(sys) can also be used to retreive and edit plot properties by using p=get(h). Here's a demo
% Produce bode plot
sys = rss(5);
h = bodeplot(sys);
p = get(h);
% Settings
p.CharacteristicManager(1).CharacteristicLabel = 'All Stability Margins';
Use bodeoptions()
Unlike the other use options above, this option allows you to specify bode plot properties before the plot is created rather than customizing the plot post hoc. opts=bodeoptions returns the default plot options for bode plots which can be customized and then applied to the bodeplot using bodeplot(..., opts). Alternatively, opts=bodeoptions('cstprefs') initializes the plot options according to the options you selected in the Control System and System Identification Toolbox Preferences Editor.
  댓글 수: 2
Andrew Hunter
Andrew Hunter 2019년 11월 26일
I dont think this has the answer but your other comment does! Replace this answer with that one.
Adam Danz
Adam Danz 2019년 11월 26일
The 2nd method "use the plot handle directly" is the approach in my previous comment. But I added the demo from my comment to make it more useful. The other two methods are to provide a more general summary of how to make changes to bode plots programmatically. Thanks for the suggestion.

댓글을 달려면 로그인하십시오.


A Jenkins
A Jenkins 2019년 12월 19일
Adam Danz's method got me started, but didn't quite get me there, and I ended up using this one: (2019a)
sys = rss(5);
h = bodeplot(sys);
h.showCharacteristic('AllStabilityMargins')

Erick Oberstar
Erick Oberstar 2022년 4월 17일
As of Matlab 2020b I can verify this works for both nyqistplot and bodeplot functions
Ts= 0.01
n = [0 0.3680 0.2640];
d = [1.0 -1.368 0.3680];
Gz = tf(n,d,Ts)
Gz.Variable = 'z^-1'
figure; h1=nyquistplot(Gz)
axis([-1.5 1.5 -1.5 1.5]); grid on;
h1.showCharacteristic('AllStabilityMargins');
%zoomcp(h1);% Optional zoom in on critical point
figure; h2 = bodeplot(Gz)
h2.showCharacteristic('AllStabilityMargins');
Note this doesn't work if you generate the plots via "bode" or "nyquist"

카테고리

Help CenterFile Exchange에서 Plot Customization에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by