Cody

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

Solution 2033032

Submitted on 23 Nov 2019 by Asif Newaz
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))

a = 4 b = 4 y = 0 0 0 0 0.5318 0.5034 0.1042 0.5539 0.4499 0.9107 0.0595 0.3291 0.8198 0.2234 0.5308 0.7760 0.9859 0.9351 0.4303 0.8012

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

a = 0 b = 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))

a = 8 b = 1 y = 0 0.3558 0.9666 0.5764 0.5116 0.8415 0.4079 0.6475 0.7920

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

a = 0 b = 1 y = 0

### Community Treasure Hunt

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

Start Hunting!