change value of nestef fields (in struct) in loop

1 visualización (últimos 30 días)
mosayyeb
mosayyeb el 18 de Oct. de 2019
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

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by