add points into bode plot - phase and magnitude

106 次查看(过去 30 天)
Hello,
I was asked to add one point in each part of the bode plot. I can plot a point in the phase part, but how can I add a point to the magnitude part?
clear all, close all, clc;
TF=tf([30 0],[1 17 30]);
bode(TF);
hold on;
plot(15,-37.4054,'*');

回答(1 个)

Star Strider
Star Strider 2016-3-19
Add a second argument with a vector of radian frequencies at which you want the bode function to evaluate your system:
[mag,phase] = bode(sys,w);
See the documentation for Bode Plot at Specified Frequencies for the details.
  2 个评论
michael
michael 2016-3-19
I familiar with this option, but this one doesn't plot the required point/frequency on the plot
Star Strider
Star Strider 2016-3-19
编辑:Star Strider 2016-3-19
I’m using (and citing the documentation of) R2016a. Again from the documentation:
H = tf([1 0.1 7.5],[1 0.12 9 0 0]);
w = logspace(-1,1,100);
bode(H,w)
This worked for me.
You have to put the angular frequencies you want into the ‘w’ vector. Add those you want to include wherever you want (beginning or end of the ‘w’ vector that covers your frequencies of interest), then use the sort function with the 'ascend' option to put it in the appropriate location in the ’w’ vector. That’s how I always do it.
This works:
H = tf([1 0.1 7.5],[1 0.12 9 0 0]);
w = logspace(-1,1,100);
w = sort([w 0.5], 'ascend'); % Add Point & Sort
wix = find(w == 0.5); % Find Index Of point
[mag,phase] = bode(H,w);
figure(1)
subplot(2,1,1)
loglog(w, squeeze(mag), w(wix), mag(1,1,wix), 'gp')
text(w(wix), mag(1,1,wix), 'Added Point\uparrow', 'HorizontalAlignment','right', 'VerticalAlignment','top')
grid
subplot(2,1,2)
semilogx(w, squeeze(phase), w(wix), phase(1,1,wix), 'gp')
text(w(wix), phase(1,1,wix), 'Added Point\uparrow', 'HorizontalAlignment','right', 'VerticalAlignment','top')
grid
EDIT — Added plot

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Plot Customization 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by