How can I use a floating point number with input command?

L = 10
a = input('Enter the location of the force (0 - %0.2f meters): ');
How can I get the prompt to output as 'Enter the location of the force (0 - 10.00 meters): '.

 Respuesta aceptada

L = 10;
S = sprintf('Enter the location of the force (0 - %0.2f meters): ',L);
a = input(S);

1 comentario

Ahh that makes sense, I tried using sprintf before but I put it on the outside so I got an error. Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 12 de Oct. de 2021

Comentada:

el 12 de Oct. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by