function [t,p] = csort0(T,P) % CSORT0 [t,p] = csort0(T,P) Sorts T, consolidates P % Version of 5/19/97 % Works with Versions 4.2 and 5 % T and P matrices with the same number of elements % The vector T(:)' is sorted: % * Identical values in T are consolidated; % (Differs from csort here) % * Corresponding values in P are added. T = T(:)'; n = length(T); [TS,I] = sort(T); d = find([1,TS(2:n) - TS(1:n-1) >0]); t = TS(d); m = length(t) + 1; P = P(I); F = [0 cumsum(P(:)')]; Fd = F([d length(F)]); p = Fd(2:m) - Fd(1:m-1);