In article <email@example.com>, "Jac " <firstname.lastname@example.org> 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%2830-x%29+%2B%281-4%2B16%2B25%29%2F%288%29 > > And here is my code: > x = 90:180; > y = 5*cos(x) - (5/4)*cos(30) - cos(30-x) +(1-4+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.