Cody

# Problem 44740. New Matrix with vector addition on diagonal

Solution 1735894

Submitted on 25 Feb 2019 by Martin C.
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
x=[1 2 3]; y=[4 5 6]; z_correct = [5 6 7;6 7 8;7 8 9] assert(isequal(addmat(x,y),z_correct))

z_correct = 5 6 7 6 7 8 7 8 9 l = 3 m = 5 0 0 0 0 0 0 0 0 m = 5 6 0 0 0 0 0 0 0 m = 5 6 7 0 0 0 0 0 0 m = 5 6 7 6 0 0 0 0 0 m = 5 6 7 6 7 0 0 0 0 m = 5 6 7 6 7 8 0 0 0 m = 5 6 7 6 7 8 7 0 0 m = 5 6 7 6 7 8 7 8 0 m = 5 6 7 6 7 8 7 8 9 m = 5 6 7 6 7 8 7 8 9

2   Pass
x=[10 20 30 40]; y=[-10 -20 -30 -40]; z_correct = [0 10 20 30;-10 0 10 20;-20 -10 0 10;-30 -20 -10 0] assert(isequal(addmat(x,y),z_correct))

z_correct = 0 10 20 30 -10 0 10 20 -20 -10 0 10 -30 -20 -10 0 l = 4 m = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 m = 0 -10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 m = 0 -10 -20 0 0 0 0 0 0 0 0 0 0 0 0 0 m = 0 -10 -20 -30 0 0 0 0 0 0 0 0 0 0 0 0 m = 0 -10 -20 -30 10 0 0 0 0 0 0 0 0 0 0 0 m = 0 -10 -20 -30 10 0 0 0 0 0 0 0 0 0 0 0 m = 0 -10 -20 -30 10 0 -10 0 0 0 0 0 0 0 0 0 m = 0 -10 -20 -30 10 0 -10 -20 0 0 0 0 0 0 0 0 m = 0 -10 -20 -30 10 0 -10 -20 20 0 0 0 0 0 0 0 m = 0 -10 -20 -30 10 0 -10 -20 20 10 0 0 0 0 0 0 m = 0 -10 -20 -30 10 0 -10 -20 20 10 0 0 0 0 0 0 m = 0 -10 -20 -30 10 0 -10 -20 20 10 0 -10 0 0 0 0 m = 0 -10 -20 -30 10 0 -10 -20 20 10 0 -10 30 0 0 0 m = 0 -10 -20 -30 10 0 -10 -20 20 10 0 -10 30 20 0 0 m = 0 -10 -20 -30 10 0 -10 -20 20 10 0 -10 30 20 10 0 m = 0 -10 -20 -30 10 0 -10 -20 20 10 0 -10 30 20 10 0 m = 0 10 20 30 -10 0 10 20 -20 -10 0 10 -30 -20 -10 0