function [h,InfResp] = fresp(PID,w)
% Frequency response of PID.

%   Author(s): Rong Chen
%   Copyright 2009 MathWorks, Inc.

% Form vector s of complex frequencies
s = ltipack.utGetComplexFrequencies(w,PID.Ts);
% convert to internal parameterization
[P,I,D,T,b,c] = utGetInternalParams(PID);
% compute frequency response of the integrator
[frP,frI,frD] = PID.utGetFreqRespParts(P,I,D,T,PID.Ts,PID.IFormula,PID.DFormula,s);
h = [frP*b + frI(:) + frD(:)*c -(frP + frI(:) + frD(:))];
% compute response of PID
h = permute(h,[3 2 1]);
% extra output
if nargout>1
    InfResp = any(isinf(h(:)));
end
