How to display pi symbol in the output?
265 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
GULZAR
am 24 Aug. 2023
Kommentiert: Hiro Yoshino
am 24 Aug. 2023
how to display pi symbol instead of numerical value in the out of the given code
clc; clear all; close all;
nA=3.3;nB=2.25;
% nB=3.3;nA=2.25;
S=sign(1-(nA^2/nB^2));
x=-1i*log(S);
if x>0
disp('Zak Phase of 0th band = ')
disp(pi)
else
disp('Zak Phase of 0th band = ')
disp('0')
end
1 Kommentar
Akzeptierte Antwort
Dyuman Joshi
am 24 Aug. 2023
You can either use the symbolic math toolbox or print the symbol via the unicode value -
nA=3.3;nB=2.25;
% nB=3.3;nA=2.25;
S=sign(1-(nA^2/nB^2));
x=-1i*log(S);
if x>0
disp('Zak Phase of 0th band = ')
%pi as a symbolic number
disp(sym(pi))
%print the symbol via unicode value
fprintf('%c', 960)
else
disp('Zak Phase of 0th band = ')
disp('0')
end
0 Kommentare
Weitere Antworten (2)
Nathan Hardenberg
am 24 Aug. 2023
Bearbeitet: Nathan Hardenberg
am 24 Aug. 2023
You can display pi as a sybolic
disp(sym(pi))
Or you can use a π-character (𝜋 or π).
disp("𝜋")
disp("π")
0 Kommentare
Hiro Yoshino
am 24 Aug. 2023
How about this?
S = sprintf('Zak Phase of 0th band = %c',960);
disp(S);
1 Kommentar
Hiro Yoshino
am 24 Aug. 2023
Please refer to the list of Unicode for your help:List of Unicode characters
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox 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!