Cody

# Problem 43007. Euclidean inter-point distance matrix

Solution 1493370

Submitted on 16 Apr 2018
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
A = eye(3); y_correct = (1-A)*sqrt(2); tol = 10*eps; assert(norm(interDist(A)-y_correct) < tol)

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-3. Error in interDist (line 7) D(i,j)=sqrt((A(i,:)-A(j,:)).^2); Error in Test1 (line 4) assert(norm(interDist(A)-y_correct) < tol)

2   Pass
A = (1:4)'; y_correct = [ 0 1 2 3;... 1 0 1 2;... 2 1 0 1;... 3 2 1 0]; tol = 10*eps; assert(norm(interDist(A)-y_correct) < tol)

3   Fail
A = magic(3); y_correct = [0 6.48074069840786 9.79795897113271; ... 6.48074069840786 0 6.48074069840786; ... 9.79795897113271 6.48074069840786 0]; tol = 1000*eps; assert(norm(interDist(A)-y_correct) < tol)

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-3. Error in interDist (line 7) D(i,j)=sqrt((A(i,:)-A(j,:)).^2); Error in Test3 (line 6) assert(norm(interDist(A)-y_correct) < tol)

4   Fail
A = reshape((1:20).^2,4,5); tol = 1e-12; y_correct = [0 49.4469412603045 102.761860629321 160.015624237135; ... 49.4469412603045 0 53.3385414123783 110.634533487515; ... 102.761860629321 53.3385414123783 0 57.3149195236284; ... 160.015624237135 110.634533487515 57.3149195236284 0]; assert(norm(interDist(A)-y_correct) < tol)

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-5. Error in interDist (line 7) D(i,j)=sqrt((A(i,:)-A(j,:)).^2); Error in Test4 (line 7) assert(norm(interDist(A)-y_correct) < tol)