Modify the input dialogue at every "for loop"?

10 Ansichten (letzte 30 Tage)
SYED GILLANI
SYED GILLANI am 16 Okt. 2016
Bearbeitet: Image Analyst am 14 Dez. 2019
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!

Akzeptierte Antwort

Image Analyst
Image Analyst am 16 Okt. 2016
Bearbeitet: Image Analyst am 14 Dez. 2019
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 Kommentare
SYED GILLANI
SYED GILLANI am 16 Okt. 2016
That helped thank you sir. Next time i'll take care about the format.
Clara Pineau
Clara Pineau am 13 Dez. 2019
Thank you, this has helped a lot.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by