MATLAB: How to Dynamic Field References in place of setfield and getfield

dynamic field referencessetfield getfieldstructure

hi i want to convert this code below to dynamic field references:
for fld = fieldnames(oi)'
o = setfield(o,fld{1},getfield(oi,fld{1}));
end
because it is showing warning an i want to convert my matlab code to c code .how shud i do that?

Best Answer

for fld = fieldnames(oi)'
o.(fld{1}) = oi.(fld{1});
end
Related Question