load morse_digits.dat

prox = morse_digits;

n = size(prox,1);

[outpermone,outpermtwo,coordone,coordtwo,fitone,fittwo,addconone,...
    addcontwo,vaf] = biscalqa(prox,targlin(n), ...
    targlin(n),randperm(n),randperm(n),3,1)

for i = 1:n
    for j = 1:n
        
        if(outpermtwo(i) == j)
            start_coordtwo(j) = coordtwo(i);
            
        end
    end
end

for i = 1:n
    for j = 1:n
        
        if(outpermone(i) == j)
            start_coordone(j) = coordone(i);
            
        end
    end
end

addcon_start = -1.0*(addconone + addcontwo);

start_vector = zeros(2*n + 1,1);

for i = 1:n
    
    start_vector(i) = start_coordone(i);
    start_vector(i+n) = start_coordtwo(i);
    
end

start_vector(2*n + 1) = addcon_start;

start_vector;

start_vector = zeros(2*n+1,1);

p  = 2

[fitted, coordone,coordtwo,addcon, fval,vaf,exitflag] = lpfit(prox,...
    outpermone,outpermtwo,start_vector,p)