source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/lightspeed/graphics/quantile.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 417 bytes
Line 
1function b = quantile(x,probs)
2% QUANTILE     Quantiles of a data vector.
3% quantile(x,probs) behaves like the R function of the same name.
4%
5% Example:
6%   quantile(3:4,[0.3 0.6])
7
8x = sort(x);
9x = x(:)';  % workaround matlab indexing bug
10pos = probs*(length(x)-1) + 1;
11pos_lower = floor(pos);
12pos_upper = ceil(pos);
13pos_frac = pos - pos_lower;
14b = x(pos_lower).*(1-pos_frac) + x(pos_upper).*pos_frac;
Note: See TracBrowser for help on using the repository browser.