How to displaying π instead of long decimal
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
Antworten (1)
Image Analyst
am 2 Jul. 2017
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 Kommentare
John D'Errico
am 3 Jul. 2017
Bearbeitet: John D'Errico
am 3 Jul. 2017
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
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!