Solve function give 2 answers when there should be 1.

My question is why the solve function returns 2 values for acos()? I'm trying to get MATLAB to solve Kepler's trajectory equation (where theta - theta0 = f1 in this case) for f1. Done manually, I get 1 answer: f1 = 2.3583 rad, but solve() returns 2 answers: 3.9249 and 2.3583. If I don't double check my answer, I might choose the wrong output. Why does MATLAB do this and how do I resolve it, or how do I know without that extra verification step which solution MATLAB gives is the correct one? It's not always the first or second element in the array, because the same exact code put in another script where r, p, and e are not hard-coded returns these 2 values switched.
----- code -----
-------------------------------------------
% example
clc;
clear all;
r = 6707.614926;
p = 5759.485421;
e = 0.19948067;
syms f1_var
eq = r == p/(1+e*cos(f1_var));
ans = solve(eq,f1_var);
f1_auto = double(ans)
f1_man = acos((1/e)*(p/r-1))
-------------------------------------------
----- results -----
f1_auto =
2.3583
3.9249
f1_man =
2.3583
-------------------------------------------
Thank you so much!

 採用された回答

James Tursa
James Tursa 2020 年 10 月 15 日
編集済み: James Tursa 2020 年 10 月 15 日

0 投票

For a generic orbit problem, i.e. an ellipse, there are always going to be two places on the orbit path with the same r value (except for the perigee and apogee points). One outgoing and one incoming. MATLAB is simply giving you both valid solutions. It is up to you to determine which one you want ... MATLAB has no way of knowing. They are both "correct" as far as solving the equation is concerned.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

製品

リリース

R2019b

タグ

質問済み:

Sam
2020 年 10 月 15 日

コメント済み:

Sam
2020 年 10 月 17 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by