function [ cdfx cdfy ] = cdf_function( data ) %CDF_FUNCTION sorted_data = sort(data); indx=1; cdfx(1) = sorted_data(1); cdfy(1) = 1;%the probability of having the number at cdfx(1) for i = 2:length(sorted_data) if sorted_data(i-1) == sorted_data(i); cdfy(indx) = cdfy(indx) + 1; else cdfy(indx+1) = cdfy(indx) + 1; cdfx(indx+1) = sorted_data(i); indx=indx+1; end end cdfy = cdfy/i; plot(cdfx, cdfy ); end