Cody

# Problem 42501. Toeplitize a matrix

Solution 1587374

Submitted on 19 Jul 2018 by Radha Kumari
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
A = 100; B = 100; assert(isequal(toeplitize(A),B))

i = 0 rep = 100 A = (1,1) 100 B = 100

2   Pass
A = [9,4;2,3;2,0]; B = [6,4;1,6;2,1]; assert(isequal(toeplitize(A),B))

i = -2 rep = 2 2 2 A = (1,1) 9 (2,1) 2 (3,1) 2 (1,2) 4 (2,2) 3 i = -1 rep = (1,1) 1 (2,1) 1 (3,1) 1 A = (1,1) 9 (2,1) 1 (3,1) 2 (1,2) 4 (2,2) 3 (3,2) 1 i = 0 rep = (1,1) 6 (2,1) 6 (3,1) 6 A = (1,1) 6 (2,1) 1 (3,1) 2 (1,2) 4 (2,2) 6 (3,2) 1 i = 1 rep = (1,1) 4 (2,1) 4 (3,1) 4 A = (1,1) 6 (2,1) 1 (3,1) 2 (1,2) 4 (2,2) 6 (3,2) 1 B = 6 4 1 6 2 1

3   Pass
A = [7,10,9;5,1,0]; B = [4,5,9;5,4,5]; assert(isequal(toeplitize(A),B))

i = -1 rep = 5 5 A = (1,1) 7 (2,1) 5 (1,2) 10 (2,2) 1 (1,3) 9 i = 0 rep = (1,1) 4 (2,1) 4 A = (1,1) 4 (2,1) 5 (1,2) 10 (2,2) 4 (1,3) 9 i = 1 rep = (1,1) 5 (2,1) 5 A = (1,1) 4 (2,1) 5 (1,2) 5 (2,2) 4 (1,3) 9 (2,3) 5 i = 2 rep = (1,1) 9 (2,1) 9 A = (1,1) 4 (2,1) 5 (1,2) 5 (2,2) 4 (1,3) 9 (2,3) 5 B = 4 5 9 5 4 5

4   Pass
A = [6 3 2 7;3 5 1 2;3 7 10 2]; B = [7,2,2,7;5,7,2,2;3,5,7,2]; assert(isequal(toeplitize(A),B))

i = -2 rep = 3 3 3 A = (1,1) 6 (2,1) 3 (3,1) 3 (1,2) 3 (2,2) 5 (3,2) 7 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