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 382428

Submitted on 9 Jan 2014 by Ziko

Correct

36Size
Leading solution size is 11.
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 = 3;
y_correct =     [ 8     0     6;
     0    10     0;
     4     0     2;]
assert(isequal(your_fcn_name(x),y_correct))
y_correct =
     8     0     6
     0    10     0
     4     0     2
M =
     8     1     6
     3     5     7
     4     9     2
ans =
     8     0     6
     0    10     0
     4     0     2
2
Pass
 
%%
x = 5;
y_correct =     [     17     0     0     0    15;
     0     5     0    14     0;
     0     0    26     0     0;
     0    12     0    21     0;
    11     0     0     0     9];
assert(isequal(your_fcn_name(x),y_correct))
M =
    17    24     1     8    15
    23     5     7    14    16
     4     6    13    20    22
    10    12    19    21     3
    11    18    25     2     9
ans =
    17     0     0     0    15
     0     5     0    14     0
     0     0    26     0     0
     0    12     0    21     0
    11     0     0     0     9
3
Pass
 
%%
x = 9;
y_correct =[47     0     0     0     0     0     0     0    45;
     0    68     0     0     0     0     0    44     0;
     0     0     8     0     0     0    43     0     0;
     0     0     0    20     0    42     0     0     0;
     0     0     0     0    82     0     0     0     0;
     0     0     0    40     0    62     0     0     0;
     0     0    39     0     0     0    74     0     0;
     0    38     0     0     0     0     0    14     0;
    37     0     0     0     0     0     0     0    35;];
assert(isequal(your_fcn_name(x),y_correct))
M =
    47    58    69    80     1    12    23    34    45
    57    68    79     9    11    22    33    44    46
    67    78     8    10    21    32    43    54    56
    77     7    18    20    31    42    53    55    66
     6    17    19    30    41    52    63    65    76
    16    27    29    40    51    62    64    75     5
    26    28    39    50    61    72    74     4    15
    36    38    49    60    71    73     3    14    25
    37    48    59    70    81     2    13    24    35
ans =
    47     0     0     0     0     0     0     0    45
     0    68     0     0     0     0     0    44     0
     0     0     8     0     0     0    43     0     0
     0     0     0    20     0    42     0     0     0
     0     0     0     0    82     0     0     0     0
     0     0     0    40     0    62     0     0     0
     0     0    39     0     0     0    74     0     0
     0    38     0     0     0     0     0    14     0
    37     0     0     0     0     0     0     0    35