% pathsLocal(el) - use Winpath_index and Winperm_index to produce
% measurement index paths for K>1 el'th best.  Default el=1.
%
% for use with PKKwindow K estimation
%
function p = pathsLocal(el)

global K;
global L;
global N;
global Winpath_index;
global Winperm_index;
global combos;
global perms;
global tr_period;

if( nargin == 0)
  el = 1;
end

if( (el < 1) | (el > L))
  error( '1 <= el <= L required');
end

if( K == 1)
  p = Winpath_index(el,:);
  return;
end

% el

p = combos(:,Winpath_index(el,:));

for i=1:tr_period
  c = p(:,i);
  p(:,i) = c(perms(:,Winperm_index(el,i)));
end

p = p';
