Cody

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

Solution 262782

Submitted on 18 Jun 2013 by andrea84
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
%% Example tested input = 1:3; output = {'1' '2' '3'}; assert(isequal(matrix2cell(input ),output)) assert(iscell(output),'output must be a cell')

``` r = 1 c = 1 ans = '1' r = 1 c = 2 ans = '1' '2' r = 1 c = 3 ans = '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 r = 1 c = 1 ans = '0' r = 1 c = 2 ans = '0' '5' ```

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

``` output = '8' '1' '6' '3' '5' '7' '4' '9' '2' r = 1 c = 1 ans = '8' r = 2 c = 1 ans = '8' '3' r = 3 c = 1 ans = '8' '3' '4' r = 1 c = 2 ans = '8' '1' '3' [] '4' [] r = 2 c = 2 ans = '8' '1' '3' '5' '4' [] r = 3 c = 2 ans = '8' '1' '3' '5' '4' '9' r = 1 c = 3 ans = '8' '1' '6' '3' '5' [] '4' '9' [] r = 2 c = 3 ans = '8' '1' '6' '3' '5' '7' '4' '9' [] r = 3 c = 3 ans = '8' '1' '6' '3' '5' '7' '4' '9' '2' ```