%% Frequency Response from Transfer Function
% Find and graph the frequency response of the transfer function
% H(s) = \frac{0.2s^2+0.3s+1}{s^2+0.4s+1}.

a = [1 0.4 1];
b = [0.2 0.3 1];
w = logspace(-1,1);

h = freqs(b,a,w);
mag = abs(h);
phase = angle(h);
phasedeg = phase*180/pi;

subplot(2,1,1)
loglog(w,mag)
grid on
xlabel('Frequency (rad/s)')
ylabel('Magnitude')

subplot(2,1,2)
semilogx(w,phasedeg)
grid on
xlabel('Frequency (rad/s)')
ylabel('Phase (degrees)')

% You can also generate the plots by calling freqs with no output arguments.

figure
freqs(b,a,w)

% Copyright 2015 The MathWorks, Inc.