Cody

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

Solution 2102615

Submitted on 22 Jan 2020 at 20:54
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   Fail
input = 1:3; output = {'1' '2' '3'}; assert(isequal(matrix2cell(input ),output)) assert(iscell(output),'output must be a cell')

Conversion to cell from char is not possible. Error in matrix2cell (line 5) output(k,j)=num2str(output{k,j}); Error in Test1 (line 3) assert(isequal(matrix2cell(input ),output))

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

input = 0 5

Conversion to cell from char is not possible. Error in matrix2cell (line 5) output(k,j)=num2str(output{k,j}); Error in Test2 (line 3) assert(isequal(matrix2cell(input ),output))

3   Fail
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'}

Conversion to cell from char is not possible. Error in matrix2cell (line 5) output(k,j)=num2str(output{k,j}); Error in Test3 (line 5) assert(isequal(matrix2cell(input ),output))