How to get the solutions of inverse cosine (acos) in the interval [0, 2π]?

73 vues (au cours des 30 derniers jours)
Giuseppe
Giuseppe le 7 Mar 2022
Modifié(e) : Torsten le 7 Mar 2022
Hi guys!
I've an expression like this one: "cos_omega = ...".
I know that the matlab function acos return only the solution in the interval [0, π].
How can I obtain the two solutions, i.e. the first one in the interval [0, π] and the second one in the interval [π, 2π]?
Is there a matlab function to perform this task?

Réponse acceptée

Torsten
Torsten le 7 Mar 2022
Modifié(e) : Torsten le 7 Mar 2022
Is there a matlab function to perform this task?
No.
But if you want to work within the branch in [0,pi] as well as in [pi,2*pi], you may define your own acos-function as
Acos_User = @(x) [acos(x),2*pi-acos(x)]
where x is given in radians.
I returns a (1x2) vector with both values.

Plus de réponses (1)

Davide Masiello
Davide Masiello le 7 Mar 2022
Modifié(e) : Davide Masiello le 7 Mar 2022
n = 10;
k = 1:n;
omegas = sort([k*2*pi-acos(cos_omega),k*2*pi+acos(cos_omega)])'
yields solutions up to [(2*n-1)*pi 2*n*pi]. For the case above
omegas =
5.6397
6.9267
11.9229
13.2099
18.2061
19.4931
24.4892
25.7762
30.7724
32.0594
37.0556
38.3426
43.3388
44.6258
49.6220
50.9090
55.9052
57.1922
62.1884
63.4754
>> cos(omegas)
ans =
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000
0.8000

Catégories

En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by