How to display a percent sign (%) using latex and sprintf
Afficher commentaires plus anciens
I am somewhat new to using latex for plot labels in MATLAB, and am having difficulty getting a percent sign to display using the combination of sprintf and latex. According to documentation for sprintf, the command for a percent sign would be this:
sprintf('New percent OS = $%.2f$ %%',percentOS)
However, this gives an error for the variable insertion portion of text,
I have also tried using the latex syntax for a percent sign, which would be:
sprintf('New percent OS = $%.2f$ $\%$',percentOS)
This gave a different error, but nonetheless did not work.
It seems that latex and sprintf having their own unique syntax is causing problems, but I am unsure what a solution would be.
Réponse acceptée
Plus de réponses (2)
David Hill
le 1 Avr 2021
sprintf('New percent OS = %s%.2f','%',percentOS);
Meg Noah
le 1 Avr 2021
0 votes
% not using latex
loveMetric = 99.99;
fprintf(2,'I love matlab: %0.8f %%\n', loveMetric);
Catégories
En savoir plus sur LaTeX dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

