Code covered by the BSD License  

Highlights from
cell2string

2.0

2.0 | 2 ratings Rate this file 12 Downloads (last 30 days) File Size: 2.04 KB File ID: #39532

cell2string

by

 

19 Dec 2012 (Updated )

cell2string(var) get the sentence which var created the input variable var must to be a cell

| Watch this File

File Information
Description

cell2string(var) get the sentence which var created
the input variable var must to be a cell, which contains double, int, int16, int32, int64, int8, logical, uint16, uint32, uint64, uint8, char

Required Products MATLAB
MATLAB release MATLAB 7.13 (R2011b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
20 Sep 2013 Jan Simon

You forgot to mention, that this function requires your struct2string() also and the other way around.

The types and sizes of the correctly treated fields/cell elements is limited, but not mentioned in the documentation. E.g. matrices with more than 2 dimensions and non-scalar LOGICALs appear confusingly in the output.

Such a function must have limitations, of course. But they must be explained clearly in the documentation. And instead of printing an incorrect string, a rejection in form of a warning or error would be smarter.

26 Dec 2012 Jan Simon

What happens for cells with more than 2 dimensions? The output for {[true, false]} is confusing, because vectors or arrays are not considered. Strings are enclosed in square brackets only, if they are not the first element in a cell.

The code can be simplified substantially. E.g.:
for i=1:f
for j=1:v
cellstring = ...
end
cellstring = [ cellstring ','];
end
instead of checking "if j==v" in each iteration and appending the comma in the last iteration only.

Adding a leading brace in the case of "cfPointer == 1 && cvPointer == 1" does not require two (almost) equal blocks of code for the conversion. This is simpler:
if cfPointer == 1 && cvPointer == 1
cellstring = [cellstring, '{'];
end
And then one conversion block is enough.

The list of allowed inputs does not contain the type cell, although this is shown in the example. But the limitation to scalar inputs is more important.

20 Dec 2012 Jan Simon

"strfind(var, '')" will not compare var with an empty string. Perhaps you want "isqual(var, '')".
The allowed types of the inputs are not explained in the help section. E.g. you check for doubles and cells only, but what happens for elements of type STRUCT, SINGLE or UINT16? E.g. the {1,1} element must be a string, but as long as this is not explained, other users will run into troubles.
Inserting empty string in "[cellstring '' num2str(var) '']" is not useful.

Currently the usability of your submissions is very limited. I will brushup my votes, if you improve the help section, more types of elements are considered, and a warning or error handles not supported types.

Updates
20 Dec 2012

1/support more data types
2/modify convert wrong bugs

19 Sep 2013

zip file

Contact us