Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: cell array of strings to structure
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
question on Lorenz equation

Posts: 160
Registered: 12/7/04
cell array of strings to structure
Posted: Jan 9, 2013 5:49 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I desire to create e.g. a structure:
>> ds=struct('name',{{'my_name_is'},{'matlab_thining_hair'}})
>> ds = 1x2 struct array with fields:

Where the call to the name field generates:
>> 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
I've tried, among other things:
Y = cell2struct(X, 'name', 1)'
which results in
>> Y = 1x2 struct array with fields:
And a call to Y generates:
>> 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 array with fields name, the field values are not formatted the same and the structures also vary in their bytes size.
Any help would be much appreciated.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.