Hi,
in my program i have a message box, which informs the user that an activity has been terminated and also display the activities consumption. Something like this: 'The activity xxx has been terminated and the consumption was 4.925971e-01 kWh'
My problem: how do i get that (fairly) ugly and unreadable value '4.925971e-01' to the handy format of '0.492'?
Cheers, Mathias

 채택된 답변

Benjamin Kraus
Benjamin Kraus 2017년 1월 24일
편집: Benjamin Kraus 2017년 1월 24일

0 개 추천

You want to use sprintf, probably something like this:
sprintf('%0.3f',val);
Or, more completely:
sprintf('The activity %s has been terminated and the consumption was %0.3f kWh', activity, val);

추가 답변 (0개)

카테고리

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

질문:

2017년 1월 24일

댓글:

2017년 1월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by