How can I set multiple variables to the same initial value efficiently?
Ältere Kommentare anzeigen
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 Kommentar
Stephen23
am 6 Dez. 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.
Akzeptierte Antwort
Weitere Antworten (1)
Anteneh Zewdu
am 6 Dez. 2018
0 Stimmen
3 Kommentare
madhan ravi
am 6 Dez. 2018
Bearbeitet: madhan ravi
am 6 Dez. 2018
Dude that's exactly what I answered , it's not nice to accept your own answer after someone has answered !
Anteneh Zewdu
am 13 Dez. 2018
madhan ravi
am 13 Dez. 2018
No problem , anytime :)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!