Cody

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

Solution 689731

Submitted on 22 Jun 2015 by Levent Zaimoglu
• Size: 17
• This is the leading solution.
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))

ans = 0 0 0 0 0.7678 0.9038 0.0969 0.2109 0.5609 0.2492 0.7832 0.8728 0.8718 0.6377 0.1770 0.4403 0.3268 0.3874 0.4252 0.4295

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

ans = Empty matrix: 1-by-0

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

ans = 0 0.9443 0.3832 0.8248 0.5651 0.5981 0.7141 0.5691 0.0407

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

ans = 0

### Community Treasure Hunt

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

Start Hunting!