%  Example 4.7.  Compare a rational approximation to a weighting function
%    with the original weighting function.
clear
%  Define the transfer function of the rational weighting function 
%  approximation.
nu=1;
de=[1 1];
%  Generate the frequency response of this transfer function.
w=logspace(-1,1);
[mag,pha]=bode(nu,de,w);
%  Define the ideal frequency response.
wideal=[.1 .9999 1.0001 10];
magideal=[1 1 0 0];
%  Plot the magnitude response of the ideal and approximation.
set(0,'DefaultAxesFontName','times')
set(0,'DefaultAxesFontSize',16)
set(0,'DefaultTextFontName','times')
figure(1)
clf
semilogx(w,mag,'r-',wideal,magideal,'r--')
axis([.1 10 0 2])
xlabel('Frequency (rad/sec)')
ylabel('Magnitude')
grid
legend('Weighting function','Ideal lowpass filter')
