Info

この質問は閉じられています。 編集または回答するには再度開いてください。

while loop mixing number with word

1 回表示 (過去 30 日間)
ali almarzooqi
ali almarzooqi 2019 年 8 月 12 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I want to change the number after the word student in while loop
a = 5;
student1 = a
a=a+5;
student2 = a
a=a+5;
student3 = a
i = 1;
a = 5;
while (i<10)
studenti = a
a=a+5;
i = i+1
end

回答 (1 件)

the cyclist
the cyclist 2019 年 8 月 12 日
編集済み: the cyclist 2019 年 8 月 12 日
Use a cell array instead:
i = 1;
a = 5;
while (i<10)
student{i} = a
a=a+5;
i = i+1
end
See this Answers tutorial about why naming variables dynamically is poor programming practice.

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by