Cody

# Problem 1812. Tridiagonal

Solution 1212114

Submitted on 14 Jun 2017 by LY Cao
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 = 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))

ans = (1,1) 2 (2,1) 1 (1,2) 3 (2,2) 2 (3,2) 1 (2,3) 3 (3,3) 2 (4,3) 1 (3,4) 3 (4,4) 2 (5,4) 1 (4,5) 3 (5,5) 2

2   Pass
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))

ans = (1,1) 5 (2,1) 9 (1,2) -17 (2,2) 5 (3,2) 9 (2,3) -17 (3,3) 5

3   Pass
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))

ans = (1,1) -1 (2,1) 4 (1,2) 8 (2,2) -1 (3,2) 4 (2,3) 8 (3,3) -1 (4,3) 4 (3,4) 8 (4,4) -1

4   Pass
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))

ans = (1,1) 21 (2,1) 11 (1,2) 30 (2,2) 21 (3,2) 11 (2,3) 30 (3,3) 21 (4,3) 11 (3,4) 30 (4,4) 21 (5,4) 11 (4,5) 30 (5,5) 21