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 346988

Submitted on 7 Nov 2013 by Chris D

Correct

29Size
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))
m =
     4
n =
     4
A =
     0     0     0     0
y =
         0         0         0         0
    0.4871    0.3276    0.9961    0.2388
    0.7446    0.5873    0.6459    0.0529
    0.1235    0.5853    0.1740    0.4387
    0.5648    0.9143    0.7346    0.7441
2
Pass
 
%%
x = [];
y_correct = zeros(1,0);
assert(isequal(addrow(x),y_correct))
m =
     0
n =
     0
A =
   Empty matrix: 1-by-0
y =
   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))
m =
     8
n =
     1
A =
     0
y =
         0
    0.4663
    0.6459
    0.2337
    0.3679
    0.5074
    0.5534
    0.4528
    0.4027
4
Pass
 
%%
x = zeros(0,1);
y_correct = 0;
assert(isequal(addrow(x),y_correct))
m =
     0
n =
     1
A =
     0
y =
     0