MATLAB: How can i print the value of a variable in the text that is to be displayed while asking for an input

variable value display

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')

Best Answer

  • E.g.
    x = input(sprintf('Enter the value of %dth variable ',i))
    or
    x = input(['Enter the value of ' num2str(i) 'th variable '])