Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SIne function in java and in matlab returns different values

Tags:

java

matlab

I want to convert my matlab code to java
In matlab I called sin(1621*2*pi*0.0001) and it returns 0.7979
now in JAVA I called Math.sin(1621*2*Math.PI*0.0001) and it returns 0.8513

Why???

The problem was I use 0.0001 as java rounded but matlab does not round it

like image 759
HK.avdalyan Avatar asked Mar 23 '26 06:03

HK.avdalyan


1 Answers

The answer is 0.8513.

When I type it in Matlab I get 0.8513 as answer.

Maybe you should check in your code if you assign not a value to "pi" that is not equal to 3.1415...

like image 102
MaxD Avatar answered Mar 24 '26 18:03

MaxD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!