from
Controller Design GUI
by Hadi Saadat Tool for the design of a first-order controller in the forward path of a closed-loop control system
ghs.m
function [mag,phase]=ghs(num,den,s)
% Copyright (C) 1998-2010 by H. Saadat.
% This function returns the magnitude and phase angle in radian of
% the open-loop transfer function G(s)H(s) for the specified complex
% variable s = + jw. Num and den are the row vectors containing
% the polynomial coefficients.
m=length(num); n=length(den);
for j= 1:m
sm(j)=s^(m-j);
end
for i=1:n
sn(i)=s^(n-i);
end
nums=sm*num';
dens=sn*den';
GH=nums/dens;
mag=abs(GH);
phase=atan2(imag(GH),real(GH));
[mag,phase];