Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 398410

Submitted on 6 Feb 2014 by Evan

Correct

18Size
Leading solution size is 18.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
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.3628    0.0488    0.9473    0.1383
    0.2488    0.4577    0.6296    0.1618
    0.4014    0.0186    0.6457    0.5811
    0.7484    0.8045    0.6002    0.3344
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.3588
    0.7032
    0.9471
    0.5727
    0.8050
    0.6987
    0.9212
    0.0058
4
Pass
 
%%
x = zeros(0,1);
y_correct = 0;
assert(isequal(addrow(x),y_correct))
ans =
     0