Complex number and degrees
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
result of code
x=3*cos(pi)+3*sin(pi)*i
is -3.0000 0.0000i.
But result of this code
x=3*cosd(180)+3*sind(180)*i
is -3.
Why result of second code is not in form -3.0000 0.0000i.???
How can I do this without transformation from deg to rad???
Thank you
x=3*cos(pi)+3*sin(pi)*
1 Kommentar
Matt Kindig
am 18 Feb. 2013
Bearbeitet: Matt Kindig
am 18 Feb. 2013
In short, numerical precision. In the first case, MATLAB represents sin(pi) as 3.6739e-16 (on my x64 machine), while in the second case, sind(180) is identically zero. Both are equivalent.
Akzeptierte Antwort
Azzi Abdelmalek
am 18 Feb. 2013
Bearbeitet: Azzi Abdelmalek
am 18 Feb. 2013
Because of precision problem with pi
sin(pi)=1.2246e-16
and
sind(180)=0
0 Kommentare
Weitere Antworten (1)
Youssef Khmou
am 18 Feb. 2013
Bearbeitet: Youssef Khmou
am 18 Feb. 2013
hi Jhon,
i can not say why using cosd and sind gives only double not complex, but you can use exponential representation which is commonly used in Elec,Eng :
R= Magnitude * exp(j* Angle ) in radian
r=3*exp(j*pi)
1 Kommentar
Siehe auch
Kategorien
Mehr zu Dates and Time 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!