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

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

"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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Anteneh Zewdu
Anteneh Zewdu 2018년 12월 6일

0 개 추천

I found the answer from a friend
[a, b, c, d] = deal(5)

댓글 수: 3

madhan ravi
madhan ravi 2018년 12월 6일
편집: madhan ravi 2018년 12월 6일
Dude that's exactly what I answered , it's not nice to accept your own answer after someone has answered !
Madhan brother, I haven't seen your answer at the time. Thanks for the help.
No problem , anytime :)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2017b

질문:

2018년 12월 6일

댓글:

2018년 12월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by