
function J = costFun(gp,gc,iaeWeights, manWeights)

% Feedback loops
gey = feedback(1,gc*gp);
ged = feedback(gp*-1,gc,1);

% Output response to input and output disturbance
sys = [gey;ged];
[e,t]=step(sys,100);

iaeTuning = iae(t,e);

J = manWeights*(iaeTuning./iaeWeights);
return
