View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

3.0 | 1 rating Rate this file 5 Downloads (last 30 days) File Size: 2.85 KB File ID: #35361 Version: 1.1



28 Feb 2012 (Updated )

simple function that converts a cell array to a string.

| Watch this File

File Information

string=array2string(array) converts a cell array to an evaluable string as used for example by eval(...). cells may contain strings, matrices, function handles and cells containing the aforementioned classes and other cells.

Required Products MATLAB
MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
09 Mar 2012 Jan Simon

Jan Simon (view profile)

You assume that the input is a 2D cell matrix, but this is not stated in the help section.
Creating the cell temp without a pre-allocation is slow. Better:
temp=reshape(array_loc', 1, []);
Checking for "length(temp)>1" in the IF condition is not needed: If temp is empty, the FOR loop body is not reached.
Please add to the help section, that SINGLE, LOGICAL, STRUCT and (U)INT8/16/32/64 data are ignored without a warning.
I'd expect that strings are enclosed in quotes. Otherwise the EVALing might lead to unexpected results. CHAR matrices let the function stop with an error.

01 Mar 2012 Rob Aberg

Rob Aberg (view profile)

If you have Simulink installed, you can also use the built-in Simulink.saveVars command to save MATLAB variables including cell arrays, structs, and objects as executable MATLAB code in .m files. See the doc for more information:

Comment only
06 Mar 2012 1.1

fixed error when length(array)==1

Contact us