Modify the input dialogue at every "for loop"?

8 ビュー (過去 30 日間)
SYED GILLANI
SYED GILLANI 2016 年 10 月 16 日
編集済み: Image Analyst 2019 年 12 月 14 日
Hello all. I am trying to make a program in which for every for loop I want to modify the input dialogue statement for example,
for i = 1:input1
for j =1:input1
input2=input('enter value of :' a[i,j] )
a(i,j)=input2;
end
end
Now here the string "enter the value of a(i,j)" so how should I write that statement so that I would get "enter the value a11" and for the next loop "enter the value a12" and so on?
Please reply ASAP!

採用された回答

Image Analyst
Image Analyst 2016 年 10 月 16 日
編集済み: Image Analyst 2019 年 12 月 14 日
Use sprintf() to make up the string:
promptString = sprintf('Please enter the value of a(%d, %d) : ', i, j);
input2 = input(promptString) % User should enter a single number now.
a(i, j) = input2;
  2 件のコメント
SYED GILLANI
SYED GILLANI 2016 年 10 月 16 日
That helped thank you sir. Next time i'll take care about the format.
Clara Pineau
Clara Pineau 2019 年 12 月 13 日
Thank you, this has helped a lot.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by