ArBa

sortIdealPoint.m

Oct 26th, 2020
740
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function [x] = sortIdealPoint(x)
  2.     idealPoint = zeros(1, size(x, 2));
  3.     for i=1:size(x,2)
  4.         idealPoint(i) = min(x(:, i));
  5.     end
  6.    
  7.     indexDist = size(x, 2) + 1;
  8.     xCopy = [x, zeros(1, size(x, 1))'];
  9.     for i=1:size(x,1)
  10.        norm(x(i, :) - idealPoint);
  11.        xCopy(i, indexDist) = norm(x(i,:) - idealPoint);
  12.     end
  13.    
  14.     x = sortrows(xCopy, indexDist);
  15.     x(:, indexDist) = [];
  16. end
RAW Paste Data