Guest User

Untitled

a guest
Oct 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. function DS = ON_2DS(O, iterations)
  2.  
  3. n = size(O,1);
  4. if(~exist('iterations','var'))
  5. iterations = 1000;
  6. end
  7.  
  8. DS = zeros(size(O));
  9. for i=1:iterations
  10. x = randn(n,1);
  11. %x=x./norm(x);
  12. y = O*x;
  13.  
  14. [~,indx] = sort(x,'ascend');
  15. [~,indy] = sort(y,'ascend');
  16.  
  17. ind = sub2ind(size(O), indy, indx);
  18. P = zeros(size(O));
  19. P(ind) = 1;
  20. DS = DS + P;
  21. end
  22.  
  23. DS = DS./iterations;
  24.  
  25. end
Add Comment
Please, Sign In to add comment