Cody

# Problem 43651. create a square matrix

Solution 2598469

Submitted on 22 Jun 2020 by Ramesh Kumar V
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
n = 3; y_correct =[1 4 9 4 4 9 9 9 9] assert(isequal(mat(n),y_correct))

y_correct = 1 4 9 4 4 9 9 9 9 z = 1 z = 1 a = 1 4 9 z = 2 z = 2 2 a = 1 4 9 4 4 9 z = 3 z = 3 3 3 a = 1 4 9 4 4 9 9 9 9 y = 1 4 9 4 4 9 9 9 9

2   Pass
n = 4; y_correct = [1 4 9 16 4 4 9 16 9 9 9 16 16 16 16 16] assert(isequal(mat(n),y_correct))

y_correct = 1 4 9 16 4 4 9 16 9 9 9 16 16 16 16 16 z = 1 z = 1 a = 1 4 9 16 z = 2 z = 2 2 a = 1 4 9 16 4 4 9 16 z = 3 z = 3 3 3 a = 1 4 9 16 4 4 9 16 9 9 9 16 z = 4 z = 4 4 4 4 a = 1 4 9 16 4 4 9 16 9 9 9 16 16 16 16 16 y = 1 4 9 16 4 4 9 16 9 9 9 16 16 16 16 16

3   Pass
n= 7; y_correct =[1 4 9 16 25 36 49 4 4 9 16 25 36 49 9 9 9 16 25 36 49 16 16 16 16 25 36 49 25 25 25 25 25 36 49 36 36 36 36 36 36 49 49 49 49 49 49 49 49] assert(isequal(mat(n),y_correct))

y_correct = 1 4 9 16 25 36 49 4 4 9 16 25 36 49 9 9 9 16 25 36 49 16 16 16 16 25 36 49 25 25 25 25 25 36 49 36 36 36 36 36 36 49 49 49 49 49 49 49 49 z = 1 z = 1 a = 1 4 9 16 25 36 49 z = 2 z = 2 2 a = 1 4 9 16 25 36 49 4 4 9 16 25 36 49 z = 3 z = 3 3 3 a = 1 4 9 16 25 36 49 4 4 9 16 25 36 49 9 9 9 16 25 36 49 z = 4 z = 4 4 4 4 a = 1 4 9 16 25 36 49 4 4 9 16 25 36 49 9 9 9 16 25 36 49 16 16 16 16 25 36 49 z = 5 z = 5 5 5 5 5 a = 1 4 9 16 25 36 49 4 4 9 16 25 36 49 9 9 9 16 25 36 49 16 16 16 16 25 36 49 25 25 25 25 25 36 49 z = 6 z = 6 6 6 6 6 6 a = 1 4 9 16 25 36 49 4 4 9 16 25 36 49 9 9 9 16 25 36 49 16 16 16 16 25 36 49 25 25 25 25 25 36 49 36 36 36 36 36 36 49 z = 7 z = 7 7 7 7 7 7 7 a = 1 4 9 16 25 36 49 4 4 9 16 25 36 49 9 9 9 16 25 36 49 16 16 16 16 25 36 49 25 25 25 25 25 36 49 36 36 36 36 36 36 49 49 49 49 49 49 49 49 y = 1 4 9 16 25 36 49 4 4 9 16 25 36 49 9 9 9 16 25 36 49 16 16 16 16 25 36 49 25 25 25 25 25 36 49 36 36 36 36 36 36 49 49 49 49 49 49 49 49

### Community Treasure Hunt

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

Start Hunting!