How can I set multiple variables to the same initial value efficiently?

17 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2018-12-6
"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.

请先登录,再进行评论。

采纳的回答

madhan ravi
madhan ravi 2018-12-6
[a,b,c,d]=deal(5)

更多回答(1 个)

Anteneh Zewdu
Anteneh Zewdu 2018-12-6
I found the answer from a friend
[a, b, c, d] = deal(5)
  3 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by