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

조회 수: 30 (최근 30일)
Gavin Thompson
Gavin Thompson 2021년 10월 12일
댓글: Gavin Thompson 2021년 10월 12일
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
Gavin Thompson
Gavin Thompson 2021년 10월 12일
Ahh that makes sense, I tried using sprintf before but I put it on the outside so I got an error. Thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by