% Example program for drawing Bode diagrams with MATLAB w = logspace(-1,4,100) ; % Logarithmically spaced set of 100 radian frequencies % between 0.1 and 10000 radians/second A = 50 ; % Frequency-independent gain zs = [0,-100] ; % Zero locations ps = [-20,-100+j*500,-100-j*500] ; % Pole locations % Compute values of H at the radian frequencies w H = A ; for n = 1:length(zs), if zs(n) == 0, H = H.*j*w ; else H = H.*(1-j*w/zs(n)) ; end end for n = 1:length(ps), if ps(n) == 0, H = H./j*w ; else H = H./(1-j*w/ps(n)) ; end end % H now contains the complex transfer function values at the radian % frequencies w % Draw the Bode diagrams subplot(2,1,1) ; p = semilogx(w,20*log10(abs(H)),'k') ; set(p,'LineWidth',2) ; xlabel('Radian Frequency, \omega','FontSize',18,'FontName','Times') ; ylabel('|H({\itj}\omega)|','FontSize',18,'FontName','Times') ; grid on ; subplot(2,1,2) ; p = semilogx(w,angle(H),'k') ; set(p,'LineWidth',2) ; xlabel('Radian Frequency, \omega','FontSize',18,'FontName','Times') ; ylabel('Phase of H({\itj}\omega)','FontSize',18,'FontName','Times') ; grid on ;