MATLAB Answers

0

Variable in Text [Matlab]

Asked by Hakan Basargan on 15 Sep 2019
Latest activity Commented on by Hakan Basargan on 16 Sep 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 Comments

Sign in to comment.

Tags

Products


Release

R2019a

2 Answers

Answer by Stephen Cobeldick on 15 Sep 2019
 Accepted Answer

  1 Comment

Thank you for your useful answer :)

Sign in to comment.


Guillaume
Answer by Guillaume
on 15 Sep 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 Comments

Sign in to comment.