add points into bode plot - phase and magnitude

조회 수: 42 (최근 30일)
michael
michael 2016년 3월 19일
편집: Star Strider 2016년 3월 19일
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