Cody

# Problem 42634. Minimum of each diagonal

Solution 2282019

Submitted on 14 May 2020
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   Pass
assert(isempty(mindiag([])))

2   Pass
x = randi(100); assert(isequal(mindiag(x),x))

3   Fail
x = randi(100,100,1); assert(isequal(mindiag(x),x(end:-1:1)'))

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. Error in mindiag (line 4) t(end+1) = min(diag(x,j)); Error in Test3 (line 2) assert(isequal(mindiag(x),x(end:-1:1)'))

4   Fail
x = randi(100,1,100); assert(isequal(mindiag(x),x))

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. Error in mindiag (line 4) t(end+1) = min(diag(x,j)); Error in Test4 (line 2) assert(isequal(mindiag(x),x))

5   Pass
x = eye(2); assert(isequal(mindiag(x),[0 1 0]))

6   Pass
x = magic(3); assert(isequal(mindiag(x),[4 3 2 1 6]))

7   Pass
x = flipud(hankel(1:1000)); assert(isequal(mindiag(x),[1:1000,zeros(1,1000-1)]))

8   Pass
x = toeplitz(1:1000); assert(isequal(mindiag(x),[1000:-1:1,2:1000]))

9   Pass
N = randi(1000); x = fliplr(toeplitz(1:N)); y = ones(1,2*N-1); y(2:2:end) = 2; assert(isequal(mindiag(x),y))

10   Fail
x = magic(10); x = x(:,1:3); assert(isequal(mindiag(x),[11 10 12 6 5 24 76 4 19 80 7 1]))

Unable to perform assignment because the left and right sides have a different number of elements. Error in mindiag (line 4) t(end+1) = min(diag(x,j)); Error in Test10 (line 3) assert(isequal(mindiag(x),[11 10 12 6 5 24 76 4 19 80 7 1]))

11   Fail
x = hankel(-4:0,0:-2:-16); assert(isequal(mindiag(x),[0 -2 -4 -6 -8 -10 -12 -14 -16 -14 -12 -10 -8]))

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. Error in mindiag (line 4) t(end+1) = min(diag(x,j)); Error in Test11 (line 2) assert(isequal(mindiag(x),[0 -2 -4 -6 -8 -10 -12 -14 -16 -14 -12 -10 -8]))

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!