% Example 5.1

RC = 0.001;
w = 0:50:5000;
H = (1/RC)./(j*w+1/RC);
magH = abs(H);
angH = 180*angle(H)/pi;
subplot(211),plot(w,magH)
title('Example 5.1')
xlabel('Frequency (rad/sec)')
ylabel('|H|')
subplot(212),plot(w,angH);
axis([0 5000 -90 0])
xlabel('Frequency (rad/sec)')
ylabel('Angle(H), degrees')
subplot(111)
pause

% The following commands are used instead if you
%   wish to plot lines that identify the points 
%   where |H|=.707 and |H|=.316.
RC = 0.001;
w = 0:50:5000;
H = (1/RC)./(j*w+1/RC);
magH = abs(H);
angH = 180*angle(H)/pi;
subplot(211),plot(w,magH)
hold on 
plot([800 1000],[.707 .707],'w:',...
   [2500 3000],[.316 .316],'w:',...
   [1000 1000],[0 .707],'w:',...
   [3000 3000],[0 .316],'w:'); 
hold off
title('Example 5.1')
xlabel('Frequency (rad/sec)')
ylabel('|H|')
text(200,.707,'0.707')
text(1800,.316,'0.316')
subplot(212),plot(w,angH);
% plot lines to identify the values at 
%   1000 and 3000 rad/sec
hold on 
plot([800 1000],[-45 -45],'w:',...
   [2500 3000],[-71.6 -71.6],'w:',...
   [1000 1000],[-90 -45],'w:',...
   [3000 3000],[-90 -71.6],'w:'); 
hold off
axis([0 5000 -90 0])
xlabel('Frequency (rad/sec)')
ylabel('Angle(H), degrees')
text(400,-45,'-45')
text(1800,-72,'-71.6')
subplot(111)
disp('The commands to compute and plot y(t)')
disp('   are given in the m-file fig5_3.m.')
