How can I set multiple variables to the same initial value efficiently?
Show older comments
I hate using the following way of defining variables;
a= 5, b=a, c=a, d=a, etc
I have a lot of variable taking the same intial value, how can do it efficiently?
Thanks in advance!
1 Comment
Stephen23
on 6 Dec 2018
"I have a lot of variable taking the same intial value, how can do it efficiently?"
Simple: store your data in one array.
Having "a lot of variables" is a sign that you should be using arrays anyway.
Accepted Answer
More Answers (1)
Anteneh Zewdu
on 6 Dec 2018
0 votes
3 Comments
madhan ravi
on 6 Dec 2018
Edited: madhan ravi
on 6 Dec 2018
Dude that's exactly what I answered , it's not nice to accept your own answer after someone has answered !
Anteneh Zewdu
on 13 Dec 2018
madhan ravi
on 13 Dec 2018
No problem , anytime :)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!