The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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,412
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$>,
"Jac " <> 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:
> 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
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]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.