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

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 %%

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

 채택된 답변

Stephan
Stephan 2019년 3월 26일
편집: Stephan 2019년 3월 26일

15 개 추천

percentError = 0.03696863;
fprintf('Percent Error: %0.8f %%', percentError);

추가 답변 (1개)

Richard Zapor
Richard Zapor 2023년 8월 31일

0 개 추천

Usage of char or '%' is possible.
fprintf('Percent Error: %0.8f %s', percentError,char(37));
or
fprintf('Percent Error: %0.8f %s', percentError,'%');

카테고리

도움말 센터File Exchange에서 Elementary Math에 대해 자세히 알아보기

질문:

2019년 3월 26일

답변:

2023년 8월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by