% Purpose:  Help function for gradient free opt. with fminsearch
% Author:   Axel Lodemel Holene
% E-mail:   axel.holene@gmail.com
% Date:     March 2013
% About:    ID = [I D] Vector of integral (and derivative) time

function J = noGrad(ctrl, parm)
    Kc = ctrl(1) ;
    ID = ctrl(2:end) ;
    MsFun = @(Kc) parm.Ms_s - Ms([Kc ID], parm) ;
    opt = optimset('Display','off','UseParallel','Always') ;
    Kc = fzero(MsFun, Kc, opt) ;       % Finding controller gain
    J  = costFun([Kc ID], parm) ;        % Calling cost function
end
