function F = lmaxcdf2(x,l,w,gbar,Etaext,Rext)
% gboundaries = w*Rext(2:end-1)';
% [d,di] = find(repmat(x,length(Rext(2:end-1)),1)>=repmat(gboundaries,1,length(x)),length(x),'first');
% F1 = expcdf(l/w*((Etaext(4:end)-Etaext(3:end-1))./(Rext(4:end)-Rext(3:end-1))),gbar)';
F2 = repmat(expcdf(l/w*((Etaext(2:end-1)-Etaext(1:end-2))./(Rext(2:end-1)-Rext(1:end-2))),gbar)'1);
F3tmp = expcdf(repmat(l*Etaext(2:end-1)',1,length(x))./(repmat(w*Rext(2:end-1)',1,length(x))...
  -repmat(x,length(Rext(2:end-1)),1)),gbar);
F3tmp(isnan(F3tmp)) = 0;
Ftmp = F3tmp - F2;
% idx = sub2ind(size(Ftmp),)
% F()
end