Displaying loop index in a string

1 vue (au cours des 30 derniers jours)
C Meek
C Meek le 28 Juin 2012
Hi all,
I'm just curious as to how to do this (or if it can even be done). If I'm using the input prompt in a loop, how can I get it to display the loop index in the string?
For example,
for k=1:NS
ele(k) = input('input value for ele(k)');
end
So essentially each time I would like this to say:
input value for ele(1)
input value for ele(2)...etc
Can this be done?
Thanks!
Craig

Réponse acceptée

Honglei Chen
Honglei Chen le 28 Juin 2012
input(sprintf('input value for ele(%d)',k))

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by