MATLAB: Using variable inside input function

input functionMATLAB

I am trying to get user input for node coordinates. For some reason the ouput in the command window does not show the variable number, but instead a square:
Input
for i =1:2
x(i)=input(['coordinate for x ' i ' in metres: ']);
end
Output
coordinate for x in metres:

Best Answer

['coordinate for x ' i ' in metres: ']
Concatenation between a character and a numeric value is define the same as if you had done
['coordinate for x ', char(i), ' in metres: ']
char(1) is the unprintable SOH (Start of Header) character, and char(2) is the unprintable STX (Start Of Text) character.
You should look at sprintf(). Or switch to string objects:
"coordinate for x " + i + " in metres: "
is well defined as formatting the number as text (according to ill-defined rules.)