Add brackets to values displayed with fprintf

Dear all,
I'm trying to use the function fprintf to display results stored in matrix A.
A = [9.9, 99];
fprintf('%0.2f ',A); fprintf('\n');
I was wondering whether it is possible to add brackets to each of the values in A1. That is, I would like the following:
(9.90) (99.00)
Thank you for your help. Best, S.

 채택된 답변

Star Strider
Star Strider 2016년 6월 7일

0 개 추천

Just include them as characters in the format descriptor string:
A = [9.9, 99];
fprintf('(%0.2f) ',A); fprintf('\n')
(9.90) (99.00)

추가 답변 (0개)

카테고리

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

태그

질문:

2016년 6월 7일

답변:

2016년 6월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by