How to get the correct asin value

4 views (last 30 days)
Mohammad
Mohammad on 27 Mar 2014
Commented: Huang Tzu-Hua on 17 Dec 2019
I have a simple question! How can I get the correct value of asin function (Inverse sin)? Consider this:
asin(sin(-3*pi/2))
The answer is pi/2. However, I need the exact value -3*pi/2 to be the result!
I'd like to thank Azzi and Walter for their answers. However. I would clarify some more aspects of the challenge that I'm trying to solve. Suppose that We have Two Signals:
Yi=X.*h_i+N_i;
Yj=conj(X).*h_j+N_j
Now, I'm trying to extract X out of Yi and Yj. I assume that N_i and N_j are White complex Gaussian noise which are uncorrelated with the data. I can't simply add them and subtract them because this would double the noise. I can extract the magnitude of x.^2 by simply:
sqrt(Yi.*Yj)
However. I'm trying to do the following for the phase:
q=Yi./Yj;
w=1./q;
ph=(asin((q-w)/2j))/2;
Which is giving me the wrong answer for X, because of the 2pi difference! Any suggestions.

Answers (2)

Walter Roberson
Walter Roberson on 27 Mar 2014
Are you requiring that asin(sin(A)) be A for all (real-valued) A ? If so then you cannot do that. sin() is a periodic function, so for any A there exists multiple B not equal to A such that sin(A) = sin(B), and asin() is not going to be able to tell the difference.
  3 Comments
Walter Roberson
Walter Roberson on 27 Mar 2014
Try with atan2() and appropriate arguments, instead of asin()
Huang Tzu-Hua
Huang Tzu-Hua on 17 Dec 2019
Great solution! You save me!

Sign in to comment.


Azzi Abdelmalek
Azzi Abdelmalek on 27 Mar 2014
You can't get -3*pi/2, you have to add k*2*pi, in your case
asin(sin(-3*pi/2))-2*pi
  4 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 27 Mar 2014
The equation
a=sin(y)
has an infinity of solutions
y=asin(a)+2*k*pi
If you have specific conditions that allows to find the appropriate values of k, you have to add them.
Mohammad
Mohammad on 27 Mar 2014
Thank you again. However, I have no means of specifying k! I added some more details to the question.

Sign in to comment.

Categories

Find more on Simulink in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!