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): '.

 채택된 답변

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

댓글 수: 1

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2021년 10월 12일

댓글:

2021년 10월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by