You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: lhs.m
    path of file: ./repos/bads/init/private
    
    the code of the file until where you have to start completion: function [X,bestscore] = lhs(N,p,LB,UB,x0,maxiter,per)
%LHS Latin hypercube sample
%
%  X = LHS(N,P) creates a Latin hypercube sample design with N points on 
%  the unit hypercube [0,1]^P.
%
%  X = LHS(N,P,LB,UB) creates a hypercube with lower/upper bounds LB and UB.

    
function [m2,row,col] = mindist(X,per)
%MINDIST Compute minimum distance between vectors in X

% Compute distance (takes into account periodic variables)
x1(:,:,1) = X;
x2(1,:,:) = X';
d2(:,:) = dist(x1,x2,per);

d2 = tril(d2,-1);
d2(d2 == 0) = Inf;
[a,row] = min(d2);
[m2,col] = min(a);
row = row(col);

% m2 = min(d2(d2 > 0));

end