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 162230

Submitted on 15 Nov 2012 by J.R.! Menzinger

Correct

26Size
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
 
%%
n=5;
[m_out{1:n}] = use_varargout(n)
Pass=true;
for i=1:n
 Pass=Pass && isequal(m_out{i},magic(i));
end
m_out{n}
assert(isequal(Pass,1))
m_out =
    [1]    [2x2 double]    [3x3 double]    [4x4 double]    [5x5 double]
ans =
    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
2
Pass
 
%%
n=7;
[m_out{1:n}] = use_varargout(n)
Pass=true;
for i=1:n
 Pass=Pass && isequal(m_out{i},magic(i));
end
m_out{n}
assert(isequal(Pass,1))
m_out =
  Columns 1 through 6
    [1]    [2x2 double]    [3x3 double]    [4x4 double]    [5x5 double]    [6x6 double]
  Column 7
    [7x7 double]
ans =
    30    39    48     1    10    19    28
    38    47     7     9    18    27    29
    46     6     8    17    26    35    37
     5    14    16    25    34    36    45
    13    15    24    33    42    44     4
    21    23    32    41    43     3    12
    22    31    40    49     2    11    20