change value of nestef fields (in struct) in loop
3 views (last 30 days)
Show older comments
Hello
I have some nested structs with many fields
I intend to produce field name and change its value in loop
I use sprintf for creating name of field
and use setfield to change value of field
but because the field name is string (and too long), I could not assing value to it. i use eval in form
for
eval (sprintf('struct name'))= setfield(eval (sprintf('struct name')), 'fieldname', 'intended value' )
end
0 Comments
Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!