MATLAB: How to plot empirical cdf in matlab release 2013a
distribution
I have matlab release 2013a but the ecdf command is not available for this release. Is there an alternative solution to plot the empirical cdf in release 2013a?.
Best Answer
One approach:
x = randn(100,1); % Create Data
binrng = linspace(-5, 5, 26); % Choose Bin Centres
hx = histc(x, binrng); % Histogram Counts
chx = cumsum(hx)/numel(x); % Cumulative Sum
figure
plot(binrng, chx)
grid
In histc, the bin ranges are the bin centres. It calculates the bin edges from them.
If you have the Statistics Toolbox, use thenormcdf function. If you don’t, use the core MATLABerfc function. That requires a bit of extra programming, but it’s definitely not complicated.
Indeed, the process of converting 3D datasets to analysis-friendly matrices is not intuitive. I have written aneof function which would accept a 20x20x100 matrix just as it is, no reshaping necessary.
Best Answer