Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
filetext = fileread('diagonalPattern.m');
assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')
|
2 | Pass |
n = 1;
mat_correct = 0;
assert(isequal(diagonalPattern(n),mat_correct))
mat =
0
|
3 | Pass |
n = -1;
mat_correct = [];
assert(isequal(diagonalPattern(n),mat_correct))
mat =
[]
|
4 | Pass |
n = 1.5;
mat_correct = [];
assert(isequal(diagonalPattern(n),mat_correct))
mat =
[]
|
5 | Pass |
n = 4;
mat_correct = [0 1 2 3
1 0 1 2
2 1 0 1
3 2 1 0];
assert(isequal(diagonalPattern(n),mat_correct))
mat =
0
mat =
0 1
mat =
0 1 2
mat =
0 1 2 3
mat =
0 1 2 3
1 0 0 0
mat =
0 1 2 3
1 0 0 0
mat =
0 1 2 3
1 0 1 0
mat =
0 1 2 3
1 0 1 2
mat =
0 1 2 3
1 0 1 2
2 0 0 0
mat =
0 1 2 3
1 0 1 2
2 1 0 0
mat =
0 1 2 3
1 0 1 2
2 1 0 0
mat =
0 1 2 3
1 0 1 2
2 1 0 1
mat =
0 1 2 3
1 0 1 2
2 1 0 1
3 0 0 0
mat =
0 1 2 3
1 0 1 2
2 1 0 1
3 2 0 0
mat =
0 1 2 3
1 0 1 2
2 1 0 1
3 2 1 0
mat =
0 1 2 3
1 0 1 2
2 1 0 1
3 2 1 0
|
6 | Pass |
n = 5;
mat_correct = [0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 1
4 3 2 1 0];
assert(isequal(diagonalPattern(n),mat_correct))
mat =
0
mat =
0 1
mat =
0 1 2
mat =
0 1 2 3
mat =
0 1 2 3 4
mat =
0 1 2 3 4
1 0 0 0 0
mat =
0 1 2 3 4
1 0 0 0 0
mat =
0 1 2 3 4
1 0 1 0 0
mat =
0 1 2 3 4
1 0 1 2 0
mat =
0 1 2 3 4
1 0 1 2 3
mat =
0 1 2 3 4
1 0 1 2 3
2 0 0 0 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 0 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 0 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 0 0 0 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 0 0 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 1
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 1
4 0 0 0 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 1
4 3 0 0 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 1
4 3 2 0 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 1
4 3 2 1 0
mat =
0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 1
4 3 2 1 0
|
Find all elements less than 0 or greater than 10 and replace them with NaN
13055 Solvers
Make one big string out of two smaller strings
1149 Solvers
Back to basics 21 - Matrix replicating
1052 Solvers
Getting the indices from a matrice
360 Solvers
559 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!