Cody

# Problem 1958. Add a row of zeros on top of a matrix

Solution 1817778

Submitted on 16 May 2019 by Zoltán Nagy
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 = rand(4); y_correct = [zeros(1,size(x,2));x]; assert(isequal(addrow(x),y_correct))

k = 4 y = 0 0 0 0 0.1943 0.8198 0.2129 0.0313 0.2123 0.9310 0.3295 0.9294 0.0209 0.7126 0.9128 0.9968 0.8313 0.5542 0.2211 0.7198

2   Pass
x = []; y_correct = zeros(1,0); assert(isequal(addrow(x),y_correct))

k = 0 y = 1×0 empty double row vector

3   Pass
x = rand(8,1); y_correct = [zeros(1,size(x,2));x]; assert(isequal(addrow(x),y_correct))

k = 1 y = 0 0.6183 0.9055 0.7909 0.8689 0.4267 0.0492 0.9375 0.3955

4   Pass
x = zeros(0,1); y_correct = 0; assert(isequal(addrow(x),y_correct))

k = 1 y = 0

### Community Treasure Hunt

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

Start Hunting!