Using fzero and plotting
8 views (last 30 days)
Show older comments
This is one problem I have been completely stuck on, any help would be appreciated. I don't even know how to start.
create a function called kepler_yourlastname (yes, that is an underscore in between kepler and yourlastname, no spaces). So, when kepler_yourlastname is run, it solves the Kepler equation for E given e and M (your function should accept M and e as inputs, and return E). The actual solution should be performed using the MATLAB built in function fzero() to solve the following form of Kepler's equation:
0 = E - e*sin[E] – M
We use this form because fzero solves for roots of the input function. Recall that fzero() is a function function, and that it that it expects that the function argument which you pass it will only accept one argument. This means that fzero(f(x)) is acceptable, but fzero(f(x,y)) is not. As such you might have to use the shared workspace property of nested functions to your advantage to complete this assignment.
Please plot E vs. M for e of values [0 0.25 0.5 0.75 1]. Please include all 5 curves in 1 figure axis, each with a different color and line style. You must label your axes and include a legend.
0 Comments
Answers (1)
Walter Roberson
on 4 Dec 2013
Start with
function E = kepler_leona(M, e)
Hint: be sure to read http://www.mathworks.com/help/matlab/ref/fzero.html "Root of Function with Extra Parameter"
0 Comments
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!