Matlab和python为sind()函数提供了不同的答案

问题描述 投票:0回答:1

我尝试在论坛中进行搜索,但未能成功找到python中的答案与Matlab中的答案不同的原因。我试图在Matlab中使用sind()函数,其中用户输入以度为单位。 Matlab代码段是,

angle = 27; b = sind(angle)

这给出b为0.4540。python中的等效代码

angle = 27;
b = math.degrees(math.sin(angle))

我得到b为54.79。

我无法解决此问题,任何输入都将非常可观。

最好的问候Pradeep

python-3.x matlab trigonometry
1个回答
0
投票

这是单元问题。在python中,math.sin()假定弧度,而不是度。 MATLAB函数sind指定度数。因此,您需要将角度转换为弧度,然后采用正弦。

这是您需要的python:

math.sin(math.radians(27))
© www.soinside.com 2019 - 2024. All rights reserved.