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