Cody

# Problem 703. Usage of varargout

Solution 1983085

Submitted on 20 Oct 2019 by Nikolaos Nikolaou
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status 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))

varargout = 1×1 cell array {[1]} varargout = 1×2 cell array {[1]} {2×2 double} varargout = 1×3 cell array {[1]} {2×2 double} {3×3 double} varargout = 1×4 cell array {[1]} {2×2 double} {3×3 double} {4×4 double} varargout = 1×5 cell array {[1]} {2×2 double} {3×3 double} {4×4 double} {5×5 double} m_out = 1×5 cell array {[1]} {2×2 double} {3×3 double} {4×4 double} {5×5 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))

varargout = 1×1 cell array {[1]} varargout = 1×2 cell array {[1]} {2×2 double} varargout = 1×3 cell array {[1]} {2×2 double} {3×3 double} varargout = 1×4 cell array {[1]} {2×2 double} {3×3 double} {4×4 double} varargout = 1×5 cell array {[1]} {2×2 double} {3×3 double} {4×4 double} {5×5 double} varargout = 1×6 cell array {[1]} {2×2 double} {3×3 double} {4×4 double} {5×5 double} {6×6 double} varargout = 1×7 cell array {[1]} {2×2 double} {3×3 double} {4×4 double} {5×5 double} {6×6 double} {7×7 double} m_out = 1×7 cell array {[1]} {2×2 double} {3×3 double} {4×4 double} {5×5 double} {6×6 double} {7×7 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