urgent help, please
Ältere Kommentare anzeigen
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!
Antworten (1)
Deepak Gupta
am 26 Mai 2020
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 Kommentare
Murad Nuri
am 26 Mai 2020
Deepak Gupta
am 26 Mai 2020
No, it's not possible as Value of N will be entered later by the user so program doesn't know in advance the value of N. Only possible way is that you use if else loops or switch case but that will be highly redundant and can cover only a finite values.
Steven Lord
am 26 Mai 2020
If you're asking if you can create N individual variables, one to store each individual m1 value, you can do this but you should not. Prefer storing them as elements in one larger variable.
Murad Nuri
am 26 Mai 2020
Steven Lord
am 26 Mai 2020
See this answer for some of the many reasons to avoid creating many individual scalar variables with numbered names.
Kategorien
Mehr zu Logical 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!