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 373479

Submitted on 21 Dec 2013

Incorrect

19Size
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))
y =
         0         0         0         0
    0.0446    0.0271    0.9205    0.2334
    0.3306    0.9845    0.8566    0.5474
    0.4779    0.1678    0.5481    0.4946
    0.3665    0.0440    0.8099    0.2369
2
Pass
 
%%
x = [];
y_correct = zeros(1,0);
assert(isequal(addrow(x),y_correct))
y =
   Empty matrix: 1-by-0
3
Fail
 
%%
x = rand(8,1);
y_correct = [zeros(1,size(x,2));x];
assert(isequal(addrow(x),y_correct))
Error: Dimensions of matrices being concatenated are not consistent.
4
Fail
 
%%
x = zeros(0,1);
y_correct = 0;
assert(isequal(addrow(x),y_correct))
Error: Assertion failed.