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

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

Added original make3d

File size: 579 bytes
Line 
1function c = cut_diverging(x,n)
2% CUT_DIVERGING     Index of sign-balanced quantiles
3% cut_diverging(x,n) is just like cut_quantile(x,n) except the negative and
4% positive numbers are each divided into n/2 quantiles.
5% In other words, it cuts x into n parts so that half go to x<0.
6%
7% Examples:
8%   cut_diverging(-2:3,2)
9%   cut_diverging(-2:3,3)
10
11n1 = floor(n/2);
12n2 = n - n1;
13ineg = find(x(:) < 0);
14i0 = find(x(:) == 0);
15ipos = find(x(:) > 0);
16c = zeros(size(x));
17c(i0) = n1+1;
18c(ineg) = cut_quantile(x(ineg),n1);
19c(ipos) = cut_quantile(x(ipos),n2-1)+n1+1;
Note: See TracBrowser for help on using the repository browser.