add points into bode plot - phase and magnitude

174 views (last 30 days)
michael
michael on 19 Mar 2016
Edited: Star Strider on 19 Mar 2016
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,'*');

Answers (1)

Star Strider
Star Strider on 19 Mar 2016
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 Comments
michael
michael on 19 Mar 2016
I familiar with this option, but this one doesn't plot the required point/frequency on the plot
Star Strider
Star Strider on 19 Mar 2016
Edited: Star Strider on 19 Mar 2016
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

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!