user1574598
user1574598

Reputation: 3881

MatLab returning different trigonometric answers than calculator?

I'm having some difficulty trying to comprehend the answers that Matlab and my calculator are returning from sinusoidal functions.

Firstly, I figured that pi/2 and 90 deg are analogous, but when I pass them into a cosine function I get these two outputs:

I have been referencing the unit circle and things don't seem to stack up. I am fairly new to maths, so maybe I may be doing something wrong. I've been practising with the sine function and this is a lot closer to my calculator results:

Upvotes: 1

Views: 4152

Answers (2)

User1551892
User1551892

Reputation: 3364

If you want to provide angle in degrees then use cosd and sind and if angle is in radians then use cos and sin.

cos(0) and cosd(0) are producing 1 on my computer. However cos(pi/2) is producing 6.1232e-17 and cosd(0) is producing 0.

you can check matlab specification which number is close to 0.

Upvotes: 4

ddelnano
ddelnano

Reputation: 469

They are only analogous if you calculator or whatever you are using to calculate is in the correct mode. For instance if you calculator is in degrees then yes cos(90) will equal 0. So it seems your calculator is in degress and not radians. I haven't used matlab in a long time so I don't know how that setting is set up but this is the problem you are experiencing. You must know when doing any trigonometric calculation for any calculator, whether that be an actual calculator or a program like matlab, if it is expecting you to enter an argument in degrees or radians.

Upvotes: 3

Related Questions