필터 지우기
필터 지우기

how can i using fprintf to write unit for a data?

조회 수: 8 (최근 30일)
Le Dung
Le Dung 2017년 5월 24일
댓글: Le Dung 2017년 5월 25일
Hi, now i trying to use fprintf to write a sentence. i want to Matlab return as below: "Max value of time is: 0.024 [s] " And i use code (below). But i can't do it. Can somebody help me? Thank you so much! My code:
time_max=0.024;
fprintf('Gia tri thoi gian ung voi chuyen vi lon nhat: %d \n',time_max,'[s]');

채택된 답변

the cyclist
the cyclist 2017년 5월 24일
편집: the cyclist 2017년 5월 24일
time_max=0.024;
fprintf('Gia tri thoi gian ung voi chuyen vi lon nhat: %7.3f [s]\n',time_max)

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 5월 24일
time_max=0.024;
fprintf('Gia tri thoi gian ung voi chuyen vi lon nhat: %g %s\n',time_max,'[s]');
Note the change from %d to %g as your data is not integer.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by