Add brackets to values displayed with fprintf

21 vues (au cours des 30 derniers jours)
Stephen
Stephen le 7 Juin 2016
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.

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Desktop dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by