Variable in Text [Matlab]
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hakan Basargan
el 15 de Sept. de 2019
Comentada: Hakan Basargan
el 16 de Sept. de 2019
Hi Team!
I havea brief question. I would like to use variable as below:
branch_ego.step.step"i".branch"j"
It's going to be like branch_ego.step.step1.branch1, branch_ego.step.step1.branch2, branch_ego.step.step2.branch3 etc.
How can I implement variable to the text variable ?
Thanks !
0 comentarios
Respuesta aceptada
Stephen23
el 15 de Sept. de 2019
You can use dynamic fieldnames:
Although using indexing would be simpler and more efficient:
Más respuestas (1)
Guillaume
el 15 de Sept. de 2019
How can I implement variable to the text variable
You don't! Numbered variables are always a bad idea. Instead you use indexing:
branch.ego.step.step(i).branch(j) = ...
See why variables should not be named dynamically for all the reasons why your initial request is a very bad idea.
0 comentarios
Ver también
Categorías
Más información sobre Startup and Shutdown 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!