Three-digit format

조회 수: 25 (최근 30일)
J T
J T 2020년 8월 21일
답변: Sara Boznik 2020년 8월 21일
Hello,
I am looking for a format such that:
fprintf( format , 1.1111111); gives 1.11
fprintf( format , 11.111111); gives 11.1
fprintf( format , 111.11111); gives 111
That is 3 digits in total regadless of the decimal point, thanks!

채택된 답변

Walter Roberson
Walter Roberson 2020년 8월 21일
%.3g

추가 답변 (1개)

Sara Boznik
Sara Boznik 2020년 8월 21일
Hi
I suggest you that you use:
fprintf('%.3g',1.111111)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by