Thank you to all who replied! Much appreciated!!
Using a variable in an input prompt
182 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
lsutiger1
am 6 Nov. 2015
Kommentiert: lsutiger1
am 6 Nov. 2015
I am trying to use the iterator (ii) of my for loop as a string in my input prompt. The code is shown below
for ii = 1:n
x = input('What is the orientation of molecule ' num2str(ii) 'in the x-direction?');
end
but this does not work. Any suggestions?
Akzeptierte Antwort
Walter Roberson
am 6 Nov. 2015
x = input(['What is the orientation of molecule ' num2str(ii) 'in the x-direction?']);
Weitere Antworten (1)
Wanbin Song
am 6 Nov. 2015
Input argument of 'input' function should be a text.
Your code shows that your input arguments of 'input' function consists of three string.
Just combine them as below.
for ii = 1:n
x = input(['What is the orientation of molecule ' num2str(ii) 'in the x-direction?']);
end
Then it will work.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!