フィルターのクリア

How to displaying π instead of long decimal

9 ビュー (過去 30 日間)
Mahome
Mahome 2017 年 7 月 2 日
コメント済み: Walter Roberson 2017 年 7 月 3 日
if I have this simple matrix
x = [0:pi/30:pi/2]
How to print the elements with "π" Greek letter instead of long decimal .. Thank you
  4 件のコメント
Walter Roberson
Walter Roberson 2017 年 7 月 3 日
Latex is not usable in the command window.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2017 年 7 月 2 日
You mean like this:
% Start string with x= and a left bracket.
asciiPi = 112
str = sprintf('x = [');
% Add the 16 elements.
for k = 0 : 15
str = sprintf('%s%d*%c/30, ', str, k, 960);
end
% Get rid of trailing slash and add right bracket.
str = [str(1:end-2), ']']
  3 件のコメント
John D'Errico
John D'Errico 2017 年 7 月 3 日
編集済み: John D'Errico 2017 年 7 月 3 日
Not really. MATLAB is a computational tool. Pi is just a number. Why worry about how it is displayed? About as much as you will do is this:
sym(pi)
ans =
pi
Walter Roberson
Walter Roberson 2017 年 7 月 3 日
sym(x) might work, possibly.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by