Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

Created by Muthu Annamalai

The MATLAB interpreter loads your code and executes it using the Read-Evaluate-Print-Loop (see REPL).

In this problem you will go the opposite way; given an in-memory MATLAB cell-array can you convert it to legal MATLAB code?

i.e. if you have the cell array,

x={{'MLB',{'Red Sox','Yankees'},{'Rangers','Cardinals'}},{'NFL',{'Cowboys','Giants'},{'Patriots','49ers','Ravens'}}}

write a function that returns the string,

y = '{{''MLB'', {''Red Sox'', ''Yankees''}, {''Rangers'', ''Cardinals''}}, {''NFL'', {''Cowboys'', ''Giants''}, {''Patriots'', ''49ers'', ''Ravens''}}};'

which on 'eval(y)' can reconstruct x.

Also specialize to handle multiple levels of cell-arrays, and mixed string/double types.

Problem Group

Solution Statistics

5 correct solutions 5 incorrect solutions
Last solution submitted on Aug 07, 2013