Cody

# Problem 1392. Convert a cell-array of values to MATLAB source code

Solution 3613585

Submitted on 10 Nov 2020
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
x = {'foo','bar',5,10, {'carrr','starr',{'rita','fereira'}}}; q = ['{''foo'', ''bar'', 5, 10, {''carrr'', ''starr'', '... '{''rita'', ''fereira''}}};'] assert(isequal(cell2str(x),q)) clear x, q x = {1,2,3,4}; q = '{1, 2, 3, 4};'; assert(isequal(cell2str(x),q)) clear x,q x = {{'MLB',{'Red Sox','Yankees'},{'Rangers','Cardinals'}},{'NFL',{'Cowboys','Giants'},{'Patriots','49ers','Ravens'}}}; q = '{{''MLB'', {''Red Sox'', ''Yankees''}, {''Rangers'', ''Cardinals''}}, {''NFL'', {''Cowboys'', ''Giants''}, {''Patriots'', ''49ers'', ''Ravens''}}};'; assert(isequal(cell2str(x),q))

q = '{'foo', 'bar', 5, 10, {'carrr', 'starr', {'rita', 'fereira'}}};'

Error using string Conversion from cell failed. Element 5 must be convertible to a string scalar. Error in cell2str (line 2) strv = string( cellV ) Error in Test1 (line 4) assert(isequal(cell2str(x),q))

### Community Treasure Hunt

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

Start Hunting!