MATLAB: How to use dot notation (substructures and fields) with a parameter which has already “dot” in it?

dot notationget_paramgetfieldMATLAB and Simulink Student Suite

Hello everyone I am new at matlab, so I think this is a very basic thing but I couldn't solve this.
I have 1×1 cells that contains field names(which they are also 1×1 substruct) of the 1×1 structure. I want to access these substructs and "their" fields with 1×1 cells, because I don't want to write all the field names one by one; I get the cells with get_param function, and I intend to use them with getfield function.
For example; Let's say main structure is " EXC " and substructure is " abc " and I want to get " data " field of abc substructure. I have " abc " field name as a 1×1 cell let's say " conS ". So I write this and I can get the data without problem;
getfield(EXC.(conS{1}), 'data')
ans =
1 0 (for example)
no problem as far but problem begins with when field name, named with also "dot" like " EXC. def ". Let's say this 1×1 cell " conR". When I use cells that have field names starting with " EXC.~~" the code does'nt work, gives this error;
getfield(EXC.(conR{1}), 'data')
Reference to non-existent field 'EXC.def'.
But when I write " EXC.def.data ", I can acces to data…
EXC.def.data
ans =
1 2 (for example)
Normally I have nx1 cells that have field names and some of them have "EXC." at their front and some of them don't have. But I need to use all of them with getfield ( or some other function) in a for loop to get their data one by one.
How can I do this? How can I use these cells that have "EXC.~~" with getfield function? or are there any other function I can use to do all of this, I really appreciate your help as I am beginner of MATLAB.
Thanks in advance, I hope I made it clear, you can ask anything that you couldn't figure out.

Best Answer

Short answer is "you can't do that!". The field name in the variable has to be a single field and a field name can't have an embedded dot within it. It's just illegal syntax and there is no way around that that is anything will recommend as a solution (even to a veteran user and certainly to a novice, anyway).
The solution is to remove the dot from the cell; if you're really trying to read an existing field but that is a field of the first such that there are two dots to dereference it as your working text example from command line, then store those as separate variables; don't try to combine them.
I'd suggest it may be you're nesting too deeply if you're running into this problem or perhaps trying to store the data in other overly-complex manner that there's a much easier solution but we can't tell much about that without more background on what you actually started with and what you're trying to accomplish.