function [mag, phase, freq] = bode2(num,den,w); %[mag, phase, freq] = bode2(num,den,w); % %'bode2' is similar to the built in 'bode' function, except %that it always plots the magnitude and phase plots regardless %of whether or not left hand (output) arguments are specified. %Also, 'bode2' displays (1) frequency, (2) log10(frequency), %(3) magnitude, (4) log10(magnitude), and (5) phase, tabulated %together in 5 columns. Again, this is shown regardless of the %specified output arguments. % %As with the 'bode' function, if no frequency vector 'w' is %specified, the frequency range will be selected automatically %and the frequency vector will contain 20+ points spaced %logarithmically within that range. If a third left hand (output) %argument (e.g. 'freq') is specified, this frequency vector will be %returned by 'bode2'. % %The maximum number of data points displayed is 50 (since 50 lines %will fit easily within a long MatLab window). If numerical data is %scrolling off the top of your MatLab window, increase the window %size. If your frequency vector is longer than 50 points, the 50 %displayed points will be evenly spaced over the full frequency range. % %EXAMPLES: % % >>bode2(num,den) :bode plot and bode data display, % frequencies selected automatically % >>bode2(num,den,w) :bode plot and bode data display, % user specified frequencies in 'w' % >>[mag,phase,w] = bode2(num,den) % :bode plot and bode data display, % frequencies selected automatically % magnitude, phase, and frequency % vectors returned in [mag, phase, w] % >>[mag,phase] = bode2(num,den,w) % :bode plot and bode data display, % user specified frequencies in 'w' % magnitude and phase at frequencies % 'w' returned in [mag, phase] % % %See also BODE, FBODE, LOGSPACE, LOGLOG, SEMILOGX, MARGIN, NICHOLS, %and NYQUIST. %This script was written by Keoki Jackson in June 1994 for the use of %6.302/16.060 students. If you find it useful, great! If you have %any problems, go bother the current TA. disp_num = 50; %number of points to display if nargin==2 [m,p,w] = bode(num,den); bode(num,den); elseif nargin==3 [m,p] = bode(num,den,w); bode(num,den,w); else disp('Number of input arguments must be 2 or 3'); error('Usage: [mag,phase,freq] = bode2(num,den,w)'); end n = size(w); if n(2)>n(1) w = w'; end %if disp(' ') disp(' Freq log(Freq) Mag log(Mag) Phase') n = length(w); if n=2 mag=m; phase=p; end %if if nargout==3 freq=w; end %if