I need to create a matlab structure as such ds=struct('name',{{'my_name_is'},{'matlab_thining_hair'}})
which stores as a 1x2 structure array with a field name. A call to ds.name
generates the output:
ds.name
ans = 'my_name_is'
ans = 'matlab_thining_hair'
Please note the single quotes in the output. They are important. That said, I need to create the above mentioned structure using the following variable: X = [1x46 char] [1x47 char]
i.e., 1x2 cell, which I believe is actually a cell array of strings. Among other things, I've tried the following:
Y = cell2struct(X, 'name', 1)'
which results in a 1x2 structure array with fields name, however a call to Y generates the output:
Y.name
ans = my_name_is
ans = matlab_thining_hair
Note that the single quotes in the output are missing, and albeit both Y and ds are 1x2 struct arrays with fields name, the field values are not formatted the same and the structures also vary in their bytes size. Essentially what I need is a struct with fields of cell arrays, where essentially each cell array consists of a unique char array. I am at a loss as how to format the field values as character arrays? Any help would be much appreciated.