Re: cos function problem (fwd)

Started by Mike Rosing July 23, 2009

I don't know if you meant to post this or not, but it's a good comment.
If that line wasn't commented out, this is something to check.

---------- Forwarded message ----------
Date: Thu, 23 Jul 2009 11:45:53 -0700 (PDT)
From: jon duncan
To: Mike Rosing
Subject: Re: [adsp] cos function problem

Mike ,

The manual states that the input is interpreted as radians here it appears that the multiplication of 180/pi is converted to degrees. I think this might be the problem.

Jon Duncan

From: Mike Rosing
To: s...@hotmail.com
Cc: a...
Sent: Thursday, July 23, 2009 7:24:33 AM
Subject: Re: [adsp] cos function problem

If this is the code you used, then it's correct. angle is set to zero
and never changed (you commented it out here).

On Thu, 23 Jul 2009, stehseen@hotmail. com wrote:

> I am using the cos function provided in ADSP218x c library. I am using it in the following function
> void GenerateFilter( short Key, short * H, short * G)
> {
> short i;
> short coeff;
> float fN=(float)N;
> float angle=0;
> float cAngle;
> float fangle=(2*3. 1415*(Key+ 0.5))/fN;
> for(i=0;i > {
> //angle=(fangle* i*180/PI) ;
> cAngle=cos(angle) ;
> coeffgle* 32767;
> H[i]=G[i]*coeff;
> angle=angle+ fangle;
> if(angle>4*PI)
> angle=angle- 4*PI;
> }
> }
> Let Key be 49. The fangle becomes 0.868739 and the angle increments by
>0.868739 in each loop. cos function assumes values in radians. When cos
>is called with 0.868739 as input the output is -8.90891e-006, againt the
>output in matlab which is 0.6458. I cant understand why is cos function
>not working properly.