Formatting floating and integer signed numbers
조회 수: 3 (최근 30일)
이전 댓글 표시
Suppose a=5 and b=-6. If I use sprintf and write sprintf("℅0.2f+℅0.2f°,a,b) we get 5.00+-6.00 as answer and not 5.00-6.00. I would like to display the answer as 5.00-6.00. How to do it?
댓글 수: 0
채택된 답변
James Tursa
2020년 6월 12일
편집: James Tursa
2020년 6월 12일
sprintf("%0.2f%+0.2f",a,b)
Having the + inside the %format stuff forces the sign to print.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 String에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!