本文介绍了在Matlab中打印非ASCII/符号字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想发表一份声明:
my_angle = 1*pi;
fprintf('My angle is %.3f pi.\n',my_angle/pi);
但产生了My angle is 1.000 pi
,而不是 actual π字符.
but that produced My angle is 1.000 pi
, instead of the actual π character.
我正在考虑某种方式使用Unicode ...
我发现了一些相关的东西:
I'm thinking some sort of use of Unicode...
I found some related things:
- Page on Unicode pi
- Sort of related SO question
- Perhaps a more relevant SO question
推荐答案
我不知道如何使用fprintf
进行操作,但是 sprintf
起作用–只需省略分号即可:
I don't know how to do it with fprintf
, but sprintf
works – just leave off the semicolon:
sprintf('My angle is %.3f %c.\n',my_angle,char(960))
或者您可以使用 disp
:
Or you can use disp
:
disp(['My angle is ' num2str(my_angle,'%.3f') ' ' char(960) '.']);
这篇关于在Matlab中打印非ASCII/符号字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!