Cody

# Problem 380. Convert a numerical matrix into a cell array of strings

Solution 1884102

Submitted on 25 Jul 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
input = 1:3; output = {'1' '2' '3'}; assert(isequal(matrix2cell(input ),output)) assert(iscell(output),'output must be a cell')

output = 1×1 cell array {'1'} output = 1×2 cell array {'1'} {'2'} output = 1×3 cell array {'1'} {'2'} {'3'} output = 1×3 cell array {'1'} {'2'} {'3'}

2   Pass
input = 0:5:8 output = {'0' '5'}; assert(isequal(matrix2cell(input ),output)) assert(iscell(output),'output must be a cell')

input = 0 5 output = 1×1 cell array {'0'} output = 1×2 cell array {'0'} {'5'} output = 1×2 cell array {'0'} {'5'}

3   Pass
input =magic(3); output = {'8' '1' '6' '3' '5' '7' '4' '9' '2'} assert(isequal(matrix2cell(input ),output))

output = 3×3 cell array {'8'} {'1'} {'6'} {'3'} {'5'} {'7'} {'4'} {'9'} {'2'} output = 1×1 cell array {'8'} output = 1×2 cell array {'8'} {'3'} output = 1×3 cell array {'8'} {'3'} {'4'} output = 1×4 cell array {'8'} {'3'} {'4'} {'1'} output = 1×5 cell array {'8'} {'3'} {'4'} {'1'} {'5'} output = 1×6 cell array {'8'} {'3'} {'4'} {'1'} {'5'} {'9'} output = 1×7 cell array {'8'} {'3'} {'4'} {'1'} {'5'} {'9'} {'6'} output = 1×8 cell array {'8'} {'3'} {'4'} {'1'} {'5'} {'9'} {'6'} {'7'} output = 1×9 cell array {'8'} {'3'} {'4'} {'1'} {'5'} {'9'} {'6'} {'7'} {'2'} output = 3×3 cell array {'8'} {'1'} {'6'} {'3'} {'5'} {'7'} {'4'} {'9'} {'2'}

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!