X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 21 May 2014 10:11 AM by  anon
Writing a simple program to calculate sin and cos of given angle and convert angle
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
21 May 2014 10:11 AM
    I'm just staring to learn how to program with IDL , and am trying to write a simple program to ask a user to input an angle in degrees and then have the program output cos(θ), sin(θ) and convert the angle to radians. This is my attempt at creating a program for just the first task of computing cos(θ) so far, but am having no luck. Please let me know if you can help. Thanks for any input! pro theta compile_opt idl2 n=0 read, n, prompt= 'Enter angle in degrees' y=cos(n) print, y end

    Deleted User



    New Member


    Posts:
    New Member


    --
    04 Jun 2014 01:29 PM
    If the problem is that the result of the cosine calculation is not coming out correct, it is probably because the COS function requires the argument to be in radians. You must first convert the numbers to radians, and perform the cosine calculation. For example: pro scratch compile_opt idl2 n=0 read, n, prompt= 'Enter angle in degrees: ' y=cos(n*!DTOR) print, y end I hope that this information will be helpful.
    You are not authorized to post a reply.