I tried cellstr in the documentation under dataset, but error.
Any hint.
You might have one of two things:
1) a dataset with a variable that's a char matrix
2) a dataset with a variable that's already a cellstr
In either case, if all you want to do is get one variable out and
convert it to a cell array of strings, you can just use the dataset's
dot subscripting to pick out the variable and convert it if necessary.
Case 1:
>> ds = dataset(['abc';'def';'ghi'])
ds =
Var1
abc
def
ghi
>> s = cellstr(ds.Var1)
s =
'abc'
'def'
'ghi'
In this case, it might make more sense to just convert it in place:
>> ds.Var1 = cellstr(ds.Var1)
ds =
Var1
'abc'
'def'
'ghi'
>> summary(ds)
Var1: [3x1 cell string]
Case 2:
>> ds = dataset({'abc';'def';'ghi'})
ds =
Var1
'abc'
'def'
'ghi'
>> s = ds.Var1
s =
'abc'
'def'
'ghi'
In this case, there's really no need to take it out of the array,
because you can refer to ds.Var1, and that _is_ a cell array of strings.
There is cellstr method for dataset that should do this for you:
>> cellstr(ds)
ans =
'abc'
'def'
'ghi'
So the fact that you said
> I tried cellstr in the documentation under dataset, but error.
makes me wonder what else is in that array.
Deep appreciation Perkins