Calculating sin and cos functions

531 vues (au cours des 30 derniers jours)
Mohsin Shah
Mohsin Shah le 29 Mai 2011
Commenté : Steven Lord le 29 Juin 2022
Hello, i calculated the value of sin(45) in Matlab, the result was sin(45)=0.8509 and for cosin i got cos(45)= 0.5253. From general mathematics we know that sin(45)=cos(45) then why Matlab is giving different results??

Réponse acceptée

Paulo Silva
Paulo Silva le 29 Mai 2011
Those functions work in radians not degrees, try this
cosd(45)
sind(45)
  3 commentaires
Abdullah Amin
Abdullah Amin le 18 Déc 2021
y=sin(-75) then y variable should carry value
+1 -1 +75 -75
Walter Roberson
Walter Roberson le 18 Déc 2021
It is not clear to me why sin() of a scalar should result in a vector of length 4 ? Or why those particular values should be output ?

Connectez-vous pour commenter.

Plus de réponses (5)

bym
bym le 29 Mai 2011
sin() & cos() arguments are in radians. If you want degrees use
sind() cosd()
  3 commentaires
Muhammed Çelik
Muhammed Çelik le 20 Avr 2020
or, you can do like this sin(degree*pi/180)
Steven Lord
Steven Lord le 20 Avr 2020
If you're going to convert degrees to radians or vice versa, use the deg2rad or rad2deg functions moved from Mapping Toolbox to MATLAB in release R2015b rather than the "magic number" of pi/180.

Connectez-vous pour commenter.


krishna sutradhar
krishna sutradhar le 23 Juin 2021
Modifié(e) : Walter Roberson le 18 Déc 2021
sin(2250 ) + cot(300 ) + tan-1 (1/2) + 10e-10 + 9x10-2 + (log1010)3 + (loge10)5
  2 commentaires
Walter Roberson
Walter Roberson le 18 Déc 2021
sind(2250) + cotd(300) + atand(1/2) + 10e-10 + 9*10^-2 + log10(10)^3 + log(10)^5
ans = 92.8037
Nishith Sarkar
Nishith Sarkar le 29 Juin 2022
Modifié(e) : Nishith Sarkar le 29 Juin 2022
Question: sin(225) + cot(30) + tan-1(1/2) + 10e-10 + 9x10-2 + (log1010)3 + (loge10)5
>> ns1=sind(225)
ns1 =
-0.7071
>> ns2=cotd(30)
ns2 =
1.7321
>> ns3=atand(1/2)
ns3 =
26.5651
>> ns4=10e-10
ns4 =
1.0000e-09
>> ns5=9*10^-2
ns5 =
0.0900
>> ns6=log10(10)^3
ns6 =
1
>> ns7=log(10)^5
ns7 =
64.7260
>> Nishith=ns1+ns2+ns3+ns4+ns5+ns6+ns7
Nishith =
93.4059

Connectez-vous pour commenter.


Vishali Bansal
Vishali Bansal le 3 Oct 2021
>> cos^-1(0.23)
  1 commentaire
Walter Roberson
Walter Roberson le 18 Déc 2021
acos(0.23)
ans = 1.3387

Connectez-vous pour commenter.


Adedotun Taiwo
Adedotun Taiwo le 14 Fév 2022
Cos(45)
  1 commentaire
Walter Roberson
Walter Roberson le 14 Fév 2022
MATLAB is case sensitive. That would not work.
Cos(45)
Unrecognized function or variable 'Cos'.
Paulo correctly answered a decade ago that if you are using degrees, use sind() and cosd()

Connectez-vous pour commenter.


Nishith Sarkar
Nishith Sarkar le 29 Juin 2022
Modifié(e) : Nishith Sarkar le 29 Juin 2022
Answer please::
x=3cos50π+10sin300π-cos100π
  2 commentaires
Walter Roberson
Walter Roberson le 29 Juin 2022
Modifié(e) : Walter Roberson le 29 Juin 2022
Pi = sym(pi);
x = 3*cos(50*Pi) + 10*sin(300*Pi) - cos(100*Pi)
x = 
2
Steven Lord
Steven Lord le 29 Juin 2022
You don't need to use Symbolic Math Toolbox here. Use the sinpi and cospi functions instead.
x = (0:8).'/2;
s = sinpi(x);
c = cospi(x);
result = table(x, s, c)
result = 9×3 table
x s c ___ __ __ 0 0 1 0.5 1 0 1 0 -1 1.5 -1 0 2 0 1 2.5 1 0 3 0 -1 3.5 -1 0 4 0 1

Connectez-vous pour commenter.

Catégories

En savoir plus sur Trigonometry dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by