Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: Complexities with how MATLAB reads functions
Posted:
Sep 8, 2012 10:33 PM


In article <k2gtb0$lu6$1@newscl01ah.mathworks.com>, "Jac " <jac_domney@hotmail.com> wrote:
> Hey Guys, essentially how i am writing my function, as MATLAB is plotting > something different to what i want. I write my function into wolfram alpha, > and obtain the desired result. However when i paste this into MATLAB the > period has been drastically reduced. > > Here is the link for what i have placed into wolfram: > http://www.wolframalpha.com/input/?i=y+%3D+5cos%28x%29++%285%2F4%29cos%2830%2 > 9++cos%2830x%29+%2B%2814%2B16%2B25%29%2F%288%29 > > And here is my code: > x = 90:180; > y = 5*cos(x)  (5/4)*cos(30)  cos(30x) +(14+16+25)/(8); > plot(x,y) > > Can someone please explain why the two methods are reading the same function > so differently, this is part of a much bigger problem which i can't move on > through until this little error is rectified. > > Any help would be so greatly appreciated! Thanks
In MATLAB, the trig functions expect their arguments to be in radians. Either multiply degrees by pi/180 or use the variants cosd, sind, etc.
 Doug Schwarz dmschwarz&ieee,org Make obvious changes to get real email address.



