📄 plotbode.m
字号:
function plotbode(w,mag,ph,linetype)
%PLOTBODE Plot Bode diagrams.
% PLOTBODE(W,MAG,PH,'linetype') plots 20*log10(MAG) and PH in
% Bode format, with grids and labels. W is the frequency vector.
% MAG and PH can be either vectors or matrices.
% `linetype' is optional. If it is present it is used to set
% the plot line or point type. See PLOT for valid line types.
%
% The two plots are drawn one above the other.
%
% PLOTBODE(W,C,'linetype') plots Bode plots of the
% complex matrix or vector C. In this form UNWRAP is applied
% to the phase before plotting.
%
% See also PLOTDB,PLOTNYQ,PLOTNIC,UNWRAP
% Dr M.P. Ford 4th August 1987, Revised J.M.Maciejowski,13 Jan 1988.
% Copyright (c) 1987,1993 by GEC Engineering Research Centre and
% Cambridge Control Ltd. All Rights Reserved.
% History:
% Two plots now drawn simultaneously in one figure, 12.7.93, JMM.
% `Help' documentation corrected slightly: units of PH are not
% knnown to plotbode. 10.7.93, JMM.
% `fixphase' replaced by `unwrap'. 29.5.93,JMM.
% MRN0015
nargs=nargin;
error(nargchk(2,4,nargs));
[m,n]=size(mag);
if (length(w)~=m)&(length(w)~=n)
error('Frequency vector does not match points, did you forget FGET?')
end
if nargs==2
linetype=' ';
[mag,ph]=r2p(mag); % ph is in degrees
ph=(180/pi)*unwrap(ph*pi/180);%`fixphase' replaced by `unwrap'.29.5.93,JMM.
end % if nargs==2
if nargs==3
if isstr(ph)
linetype=ph;
[mag,ph]=r2p(mag); % ph is in degrees
ph=(180/pi)*unwrap(ph*pi/180);%`fixphase'replaced by `unwrap'.29.5.93,JMM.
else
linetype=' ';
end
end % if nargs ==3
if linetype==' ' % do not have linetype
subplot(2,1,1)
semilogx(w,20*log10(mag)),grid,xlabel('FREQUENCY'),ylabel('MAG dB')
subplot(2,1,2)
semilogx(w,ph),grid,xlabel('FREQUENCY'),ylabel('PHASE')
else
subplot(2,1,1)
semilogx(w,20*log10(mag),linetype),grid,xlabel('FREQUENCY'),...
ylabel('MAG dB')
subplot(2,1,2)
semilogx(w,ph,linetype),grid,xlabel('FREQUENCY'),ylabel('PHASE')
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -