how to Dynamic Field References in place of setfield and getfield ?

5 次查看(过去 30 天)
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?

采纳的回答

Walter Roberson
Walter Roberson 2015-6-21
for fld = fieldnames(oi)'
o.(fld{1}) = oi.(fld{1});
end
  3 个评论
Newman
Newman 2015-6-23
@Walter Roberson one more doubt. whn i am writing this new code instead of setfield and getfield it is still saying that: code generation only supports cell variations for varargin and vararout. So is there any other way to write the above code???

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by