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,'*');
0 个评论
回答(1 个)
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);
2 个评论
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 Center 和 File Exchange 中查找有关 Plot Customization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!