How do I print a "%" when using fprintf?
713 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alexandria Wynn
am 26 Mär. 2019
Beantwortet: Richard Zapor
am 31 Aug. 2023
I need to have the display window have a "%" after the rest of my printing.
My code looks likes this:
fprintf('Percent Error: %0.8f %', percentError);
It is currently printing "Percent Error: 0.03696863 ", but I need it to print "Percent Error: 0.03696863%"
1 Kommentar
Stephen23
am 27 Mär. 2019
The fprintf documentation explains how to define special characters, in the table entitled Special Character it shows:
Special Character Representation
Single quotation mark ''
Percent character %%
Akzeptierte Antwort
Weitere Antworten (1)
Richard Zapor
am 31 Aug. 2023
Usage of char or '%' is possible.
fprintf('Percent Error: %0.8f %s', percentError,char(37));
or
fprintf('Percent Error: %0.8f %s', percentError,'%');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!