フィルターのクリア

urgent help, please

3 ビュー (過去 30 日間)
Murad Nuri
Murad Nuri 2020 年 5 月 26 日
コメント済み: Steven Lord 2020 年 5 月 26 日
Imagine,
N=input("Enter the number of storeys: ")
m1=input("what is you m1 value? ")
As you see in the first command i ask a user to input the number of storeys. Now, my question is that i want the m1 input command to pop up N times which was entered in the first command. How can I possibly do this?
Can anyone help me on this basic issue? Thank you!

回答 (1 件)

Deepak Gupta
Deepak Gupta 2020 年 5 月 26 日
If you want to enter the values one by one, then you can use a loop:
N=input("Enter the number of stories: ")
for index = 1:N
m1(index)=input("What is your m1 value? ")
end
  5 件のコメント
Murad Nuri
Murad Nuri 2020 年 5 月 26 日
Thank you both for your help.
What is the reason I should not do that. Furthermore, am I able to choose from the general variable m vector assigned? I mean I tried the code preferred by Mr. Gupta, and the assigned m vector has appeared to be a vector with N number of values.
Steven Lord
Steven Lord 2020 年 5 月 26 日
See this answer for some of the many reasons to avoid creating many individual scalar variables with numbered names.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by