Cody

# Problem 1812. Tridiagonal

Solution 1919232

Submitted on 2 Sep 2019
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 = 1; b = 2; c = 3; n = 5; y_correct = [ 2 3 0 0 0; 1 2 3 0 0; 0 1 2 3 0; 0 0 1 2 3; 0 0 0 1 2]; assert(isequal(tridiag(a, b, c, n),y_correct))

Error using ones Size inputs must be scalar. Error in tridiag (line 2) a=diag(a*ones([1 n-1],-1)) Error in Test1 (line 10) assert(isequal(tridiag(a, b, c, n),y_correct))

2   Fail
a = 9; b = 5; c = -17; n = 3; y_correct = [ 5 -17 0 ; 9 5 -17 ; 0 9 5 ]; assert(isequal(tridiag(a, b, c, n),y_correct))

Error using ones Size inputs must be scalar. Error in tridiag (line 2) a=diag(a*ones([1 n-1],-1)) Error in Test2 (line 8) assert(isequal(tridiag(a, b, c, n),y_correct))

3   Fail
a = 4; b = -1; c = 8; n = 4; y_correct = [-1 8 0 0; 4 -1 8 0; 0 4 -1 8; 0 0 4 -1]; assert(isequal(tridiag(a, b, c, n),y_correct))

Error using ones Size inputs must be scalar. Error in tridiag (line 2) a=diag(a*ones([1 n-1],-1)) Error in Test3 (line 9) assert(isequal(tridiag(a, b, c, n),y_correct))

4   Fail
a = 11; b = 21; c = 30; n = 5; y_correct = [21 30 0 0 0; 11 21 30 0 0; 0 11 21 30 0; 0 0 11 21 30; 0 0 0 11 21]; assert(isequal(tridiag(a, b, c, n),y_correct))

Error using ones Size inputs must be scalar. Error in tridiag (line 2) a=diag(a*ones([1 n-1],-1)) Error in Test4 (line 10) assert(isequal(tridiag(a, b, c, n),y_correct))