Help me with this loop. contains handles structure
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Waboraro Olefile
el 9 de Sept. de 2016
Comentada: Waboraro Olefile
el 11 de Sept. de 2016
i have 16 objects, with tag 'box1,box2,box3.....' What i want is for the loop to access each of the objects and alter its property, either Color or any other property. how do i do this within a loop.
rcolour is just a custom function you can ignore it
for i=1:16 bcolour=rcolour() handles.box(i).BackgroundColor=bcolour; end
2 comentarios
Respuesta aceptada
Henry Giddens
el 11 de Sept. de 2016
If you want to do it like this, you can access structure fields using strings by enclosing the string referring to the fieldname in brackets. For your case:
for i = 1:16
str = sprintf('box%d',i);
handles.(str).BackgroundColor = bcolor; %
end
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!