function [g,rGns]=ps14d_6242_2004(n) % function [g,rGns]=ps14d_6242_2004(n) % % H-Infinity error calculation for Problem 1.4(d) in 6.242/2004 N=10000; % number of samples rGn=((n-1)/n)*ps14a_6242_2004(n); % reduced model w=(1:N)'*100/N; % frequency samples sqrts=((1+j)/sqrt(2))*sqrt(w); % sqrt(s) samples rGns=freqresp(rGn,w); % rho(n)*Gn samples rGns=squeeze(rGns); Gs=2./(sqrts.*(exp(sqrts)-exp(-sqrts))); % G samples g=max(abs(rGns-Gs)); close(gcf) % a graphic sanity check subplot(2,1,1); plot(w,real(rGns),w,real(Gs)); grid subplot(2,1,2); plot(w,imag(rGns)+1./w,w,imag(Gs)+1./w); grid