function [Dzero] = fun(kc)

global gc gp y t

%flagg = 0;

%while flagg == 0;

gc = controller(0,kc,0);

sim('sys_model')

[pks,locs] = findpeaks(y);

%if size(locs,2) == 0;
%    kc=kc+1;
%else
%    flagg = 1;
%end

%end
t_yp = t(locs(1));

y_max = pks(1);

y_inf = y(end);

D = (y_max-y_inf)/y_inf;

Dzero = D-0.3;

end
