How do I print a "%" when using fprintf?
713 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Stephen23
2019 年 3 月 27 日
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 %%
採用された回答
その他の回答 (1 件)
Richard Zapor
2023 年 8 月 31 日
Usage of char or '%' is possible.
fprintf('Percent Error: %0.8f %s', percentError,char(37));
or
fprintf('Percent Error: %0.8f %s', percentError,'%');
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!