# How to display the celcius sumbol (°C) using fprint??

183 views (last 30 days)
Fotis on 23 Jun 2015
Commented: Walter Roberson on 4 Dec 2019
I am creating an output file using fprint and want to display the unit of temperature in Celcius. Anyone knows how to do this?
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Stephen23 on 23 Jun 2015
Edited: Stephen23 on 4 Dec 2019
Here are four methods:
fid = fopen('temp.txt','wt');
fprintf(fid,'symbol one: °C\n');
fprintf(fid,'symbol two: %cC\n',176);
fprintf(fid,'symbol three: %cC\n',char(176));
fprintf(fid,'symbol four: \260C\n');
fclose(fid);
And the generated file:
symbol one: °C
symbol two: °C
symbol three: °C
symbol four: °C
EDIT: Added octal syntax based on Walter Roberson's comment.
##### 7 CommentsShowHide 6 older comments
Stephen23 on 4 Dec 2019
Edited: Stephen23 on 4 Dec 2019
"but how did you know the degree symbol was \260?"
Simply convert decimal to octal: 176 (decimal) = 260 (octal).
The fprintf documentation give two syntaxes for specifying any unicode character directly:
• using hexadecimal '\xN'
• using octal '\N'
The value 176 is decimal, so it cannot be used directly with either of those syntaxes, but if you convert it to the correct base it it will work exactly as documented (although watch out for the catch that Walter Roberson showed when using hexadecimal with a trailing 'C' character).

Sign in to comment.

### More Answers (1)

Ingrid on 23 Jun 2015
first search the previous answers and you will find what you are looking for: http://www.mathworks.com/matlabcentral/answers/32376-degree-symbol
I prefer to use:
^{\circ}
##### 2 CommentsShowHide 1 older comment
Walter Roberson on 4 Dec 2019
\circ is also a work-around. I am told that publications do not like \circ as it is not considered a correct degree symbol. I seem to recall it is not raised at the correct height for a proper degree symbol.

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!