Cody

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

Solution 1198974

Submitted on 27 May 2017 by Augusto Mazzei
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))

y = 0 0 0 0 0.6987 0.2760 0.4481 0.1834 0.7765 0.8288 0.9670 0.2522 0.8855 0.4919 0.9727 0.4114 0.7453 0.3694 0.2423 0.4425

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

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

y = 0 0.2558 0.0444 0.5683 0.6065 0.3694 0.7800 0.2581 0.1839

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

y = 0

Suggested Problems

More from this Author31

Community Treasure Hunt

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

Start Hunting!