access component with variable
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jonas Ström Seez
el 8 de Abr. de 2020
Comentada: Jonas Ström Seez
el 8 de Abr. de 2020
Hi!
I am wondering if there is any good way to access component with a string variable. Let me give an example.
I got an array of strings and want to loop through them to access value of every component.
components = ["componentName1", "componentName2", "componentName3", ... ]
for i = 1:length(components)
value = app.components(1, i).Value
end
To clarify component(1, i) is a string and not an object inside of app, however the string has the name of that component.
I appreciate any help I can get!
0 comentarios
Respuesta aceptada
Guillaume
el 8 de Abr. de 2020
for i = 1:numel(components) %prefer numel to length
value = app.(Components(i)).Value; %prefer 1D indexing with vectors
%..
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings 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!