File Exchange

image thumbnail


version 1.4 (2.04 KB) by

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



View License

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

Comments and Ratings (3)

Jan Simon

Jan Simon (view profile)

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.

Jan Simon

Jan Simon (view profile)

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 = ...
  cellstring = [ cellstring ','];
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, '{'];
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.

Jan Simon

Jan Simon (view profile)

"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.



zip file


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

MATLAB Release
MATLAB 7.13 (R2011b)
Tags Add Tags

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

» Watch video