function mcd_collapsesc N = 10; for t=1:100000 A = pnormdim(rand(N),1); [h0,i0,j0] = SC(A); merge = setdiff(1:N,i0); %i = round(randinseg(1,N-1)); %tha = pnormdim(rand(i,1),1); tha = pnormdim(rand(N-1,1),1); %A1 = collapse(A,1:i,tha); A1 = collapse(A,merge,tha); g = (SC(A1)<=SC(A)+1e-10); fprintf('T=%d \n',t); if ~g 'problem!!!!' keyboard end end return function [h,i0,j0] = SC(AA) % the "stricture coefficient" of AA [n,n,T] = size(AA); h = 0; for t=1:T A = AA(:,:,t); for i=1:n for j=i+1:n x = A(:,i); y = A(:,j); hxy = max(abs(x-y)); if (hxy>h) i0=i;j0=j;h=hxy; end end end end return