function F = ss_init2(x)

% steady-state program for ekf_PH3d_fc_rec3
global T;global U;global t;global d;global nt;

U1 = mean(U(48-nt+1:48,1),1)/1000;
U2 = mean(U(48-nt+1:48,2),1)/1000;
U3 = mean(U(48-nt+1:48,3),1)/1000;
U4 = mean(U(48-nt+1:48,4),1)/1000;
U5 = mean(U(48-nt+1:48,5),1)/1000;

%d=x(5);
n =nt;
wl = x(1);
wh = x(2);
pl(1,1) = exp(-exp(x(3)));
ph(1,1) = exp(-exp(x(4)));

for i=2:n
pl(i,1) = exp(-exp(x(3)+(i-1)*d));
ph(i,1) = exp(-exp(x(4)+(i-1)*d));
end

uhat(1,1) = wl+wh;
for j=2:n
uhat(j,1) = wl*prod(pl(1:j-1,1),1)+wh*prod(ph(1:j-1,1),1);
end

uhat1 = uhat(1,1);
uhat23 = sum(uhat(2:3,1),1);
uhat46 = sum(uhat(4:6,1),1);
uhat712 = sum(uhat(7:12,1),1);
uhat13 = sum(uhat(13:n,1),1);

X = [uhat1-U1;
     uhat23-U2;
     uhat46-U3;
     uhat712-U4;
     uhat13-U5];

F = 10000*(X'*X);
