why does the output show % when i type fprintf('%%')

 채택된 답변

Star Strider
Star Strider 2022년 3월 17일

0 개 추천

In the documentation section on formatSpec see the section on Text Before or After Formatting Operators.

댓글 수: 4

r=99
fprintf('%d%%',r)
so when i type this i get 99%. So it's(%%) use is only to print or show percent
Yes.
The ‘%’ sign is a format operator for fprintf (and similar functions) so in order to print it as a percent sign, it must be ‘escaped’ by using .'%%'. Similarly, in order to print a ‘\’ it is necessary to ‘escape’ it as well '\\'. See the documentation section I linked to for a full discussion of all of them.
Sanjay N
Sanjay N 2022년 3월 17일
편집: Sanjay N 2022년 3월 17일
Thank you
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2020a

질문:

2022년 3월 17일

댓글:

2022년 3월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by