How to display a percent sign (%) using latex and sprintf
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (2)
David Hill
il 1 Apr 2021
sprintf('New percent OS = %s%.2f','%',percentOS);
Meg Noah
il 1 Apr 2021
0 voti
% not using latex
loveMetric = 99.99;
fprintf(2,'I love matlab: %0.8f %%\n', loveMetric);
Categorie
Scopri di più su LaTeX in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

