Code covered by the BSD License  

Highlights from
array2string.zip

3.0

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

array2string.zip

by

 

28 Feb 2012 (Updated )

simple function that converts a cell array to a string.

| Watch this File

File Information
Description

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

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

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: http://www.mathworks.com/help/toolbox/simulink/slref/simulink.savevars.html

Updates
06 Mar 2012

fixed error when length(array)==1

Contact us