Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Complexities with how MATLAB reads functions
Replies: 1   Last Post: Sep 8, 2012 10:33 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Doug Schwarz

Posts: 1,379
Registered: 12/7/04
Re: Complexities with how MATLAB reads functions
Posted: Sep 8, 2012 10:33 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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%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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.