Hi everyone,
I have a cell array of cfit objects, let's call it objArray. I want to copy several fields (or I guess I should call them attributes) from this objArray to build a struct array. I know I can do it the following way :
mystruct = cellfun(@(x) struct('field1',x.field1,'field2',x.field2), objArray,'UniformOutput',true);
However I would like a way of doing this with a function that takes as input objArray as well as a cell array containing the names of the fields I am willing to copy. It would look like this :
mystruct = obj2struct(objArray,fieldNames);
Any help is welcome 🙂 thanks
Best Answer