Modify the input dialogue at every "for loop"?
6 views (last 30 days)
Show older comments
SYED GILLANI
on 16 Oct 2016
Edited: Image Analyst
on 14 Dec 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!
1 Comment
Image Analyst
on 16 Oct 2016
To format http://www.mathworks.com/matlabcentral/answers/13205#answer_18099 (I fixed it for you this time).
Accepted Answer
Image Analyst
on 16 Oct 2016
Edited: Image Analyst
on 14 Dec 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 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!