How can i print the value of a variable in the text that is to be displayed while asking for an input?
4 views (last 30 days)
Show older comments
Md Sahil Hassan
on 18 Aug 2017
Commented: Md Sahil Hassan
on 19 Aug 2017
For example, in the following code I want to put the value of variable i in the text to be displayed. How can I do that?
x = input('Enter the value of *i* th variable')
0 Comments
Accepted Answer
James Tursa
on 18 Aug 2017
Edited: James Tursa
on 18 Aug 2017
E.g.
x = input(sprintf('Enter the value of %dth variable ',i))
or
x = input(['Enter the value of ' num2str(i) 'th variable '])
More Answers (1)
Fangjun Jiang
on 18 Aug 2017
i=3;
string=sprintf('Enter the value of %d th variable',i);
x=input(string);
See Also
Categories
Find more on Call Python from MATLAB 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!