% Function for calculating the Ms value
% witen by: Chriss Grimholt 11 jan. 2012

function [w] = ms2(gp, gc)
log_w = logspace(-4,4,40000);
[~,index_log_w] = max(abs(freqresp(feedback(1,gp*gc),log_w)));
w = log_w(index_log_w);
[w, ms] = fminsearch(@(w) -abs(freqresp(feedback(1,gp*gc),w)),w);
ms=-ms;
return