MATLAB Answers

Error using ==> asind Argument should be real.

1 view (last 30 days)
can any one tell what this is this error

  0 Comments

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 24 Nov 2020
So what is the problem? It seems the error message states exactly what happened, and why MATLAB sees a problem.
Honestly, it just seems you are typing random commands on the command window, withough thinking of what makes mathematical sense. Eventually, you will type something that fails to produce a valid result. This might be called the inverse monkey phenomenon - a gazzillion chimpanzees might eventually type the works of Shakespeare, clicking on keys at random. However it is far easier for one person to type something at random and get something mathematically meaningless, or at least, meaningless to MATLAB.
In this case, in x1 and y1 we see you trying to compute the inverse cosine of numbers that fall outside of the domain of the acos function (or acosd for that matter.) No problem, because acos can handle any input from the real line, though outside of [-1,1], the result will be complex. That is expected.
Then you tried taking a vector that varies from 0 - 40. Cubed the elemnts, multiplied by 2, for some random reason, and used acosd. Again, no problem. But you should expect that acosd will return complex arguments. But then you tried to compute the asind on that result. Read the error message.

  0 Comments

Sign in to comment.

More Answers (1)

dpb
dpb on 24 Nov 2020
Working as documented...
ACOSD()
Description
Y = acosd(X) returns the inverse cosine (cos-1) of the elements of X in degrees. The function
accepts both real and complex inputs.
For real values of X in the interval [-1, 1], acosd(X) returns values in the interval [0, 180].
For values of X outside the interval [-1, 1] and for complex values of X,
acosd(X) returns complex values.

  0 Comments

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by