Search code examples
matlabcell

How to creates a value in a cell nested in a cell


This seems like a very easy question but I can't seem to work it out. Basically I have a number of cells: Face1, Face2, Scene1, Scene2. Each cell contains a value, for instance, Face1=15, Face2=23, Scene1=46, Scene2=9

Now I would like to group all these cells into one single cell called D, something like this D={Face1,Face2,Scene1,Scene2}. However, when I do this I get D={15,23,46,9}. This is not what I want. I'd like to keep the identity of each cell so when I call D{1,1} I'll get Face1, and when I call Face1, I'll get 15.

Does anyone have a suggestion?

Thanks!


Solution

  • Have you considered using structures? Try this:

    D.face1 = 15
    D.face2 = 23
    

    You could also do it like this:

    D.face(1) = 15
    

    Let me know if that doesn't do it for you.