MATLAB: How to make an eCDF with infinite values stored in 1 dimension


I want to make an empirical CDF stored in one dimension. See below.
vals = [1,2,3,4,5,Inf,Inf,Inf,Inf,Inf];
time = 0:9;
[F,t] = ecdf(vals);
[tUnique, tUniqueIdx] = unique(t);
CDF_1D = interp1(tUnique, F(tUniqueIdx), time, 'previous');
However, I get the error: The coordinates of the input points must be finite values; Inf and NaN are not permitted.
I want my CDF to look something like this:

Best Answer

  • CDF_1D = interp1(tUnique(1:end-1), F(tUniqueIdx(1:end-1)), time, 'previous');