how can i edit the input prompt while using inside a loop

6 ビュー (過去 30 日間)
RISHABH RISHABH
RISHABH RISHABH 2021 年 5 月 22 日
コメント済み: RISHABH RISHABH 2021 年 5 月 22 日
I want to input the string-'The value of lower bound of variable no 1', abd then i want that the value 1 will be replaced by 2 and 3 and so on. i am trying this, but is not correct. help please
n = 5;
i =1
while(i<=n)
a = input(['Enter the value of Lower Bound' (i) '\n a ='])
end

採用された回答

David Fletcher
David Fletcher 2021 年 5 月 22 日
編集済み: David Fletcher 2021 年 5 月 22 日
n = 5;
i=1;
while(i<=n)
prompt=sprintf('Enter the value of Lower Bound %d \n a =',i);
a = input(prompt)
i=i+1;
end
or, if you want to retain the input values in an array
n = 5;
i=1;
while(i<=n)
prompt=sprintf('Enter the value of Lower Bound %d \n a =',i);
a(i) = input(prompt)
i=i+1;
end

その他の回答 (0 件)

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by