Borrar filtros
Borrar filtros

Displaying loop index in a string

5 visualizaciones (últimos 30 días)
C Meek
C Meek el 28 de Jun. de 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

Respuesta aceptada

Honglei Chen
Honglei Chen el 28 de Jun. de 2012
input(sprintf('input value for ele(%d)',k))

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by