From: Joe Drapa on

Hi,

I've written a function that creates a variable which is a cell array of strings. Using "whos", I can see that this cell array is of "cell" class within this function, but after leaving the function, this variable is getting converted into "char" class.

How do I prevent this from happening? In other words, I'd like this cell array of strings to remain of "cell" class, and not get converted into "char" class when leaving the function.

My code, briefly:

- - -

cellVar = {};

string1 = 'text1';
string2 = 'text2';

cellVar{1,1} = string1;
cellVar{2,1} = string2;

- - -

Thanks in advance,

Joe



From: us on
"Joe Drapa" <remove.this.joedrapa(a)hotmail.com> wrote in message <i3c83i$jrc$1(a)fred.mathworks.com>...
>
> Hi,
>
> I've written a function that creates a variable which is a cell array of strings. Using "whos", I can see that this cell array is of "cell" class within this function, but after leaving the function, this variable is getting converted into "char" class.
>
> How do I prevent this from happening? In other words, I'd like this cell array of strings to remain of "cell" class, and not get converted into "char" class when leaving the function.
>
> My code, briefly:
> string1 = 'text1';
> string2 = 'text2';
> cellVar{1,1} = string1;
> cellVar{2,1} = string2;

well... tell CSSM: what happens BEFORE you leave the function...

us
From: Andy on
"Joe Drapa" <remove.this.joedrapa(a)hotmail.com> wrote in message <i3c83i$jrc$1(a)fred.mathworks.com>...
>
> Hi,
>
> I've written a function that creates a variable which is a cell array of strings. Using "whos", I can see that this cell array is of "cell" class within this function, but after leaving the function, this variable is getting converted into "char" class.
>
> How do I prevent this from happening? In other words, I'd like this cell array of strings to remain of "cell" class, and not get converted into "char" class when leaving the function.
>
> My code, briefly:
>
> - - -
>
> cellVar = {};
>
> string1 = 'text1';
> string2 = 'text2';
>
> cellVar{1,1} = string1;
> cellVar{2,1} = string2;
>
> - - -
>
> Thanks in advance,
>
> Joe
>
>
>


But of course after running this code:

>> class(cellVar)
ans =
cell

You're not telling us the whole story. What exactly is being converted?