Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Undefined function or method 'atan2' for input arguments of type 'sym'

Subject: Undefined function or method 'atan2' for input arguments of type 'sym'

From: Markus

Date: 5 Jan, 2012 09:41:08

Message: 1 of 7

I like to run the following lines of code

syms theta alpha x y
alpha = atan2(y,x)
subs(theta, {x y}, {pi/4 pi/4})
theta = diff(alpha, x);

But I am getting an error on the second line:
??? Undefined function or method 'atan2' for input arguments of type 'sym'.
Any Ideas how to solve this problem?

Thanks
Markus

PS.: Substituing atan2 with 2*atan( (sqrt(x^2+y^2)-x)/y) will give me trubles on y == 0 so I dont want to do that.

Subject: Undefined function or method 'atan2' for input arguments of type 'sym'

From: Torsten

Date: 5 Jan, 2012 09:52:39

Message: 2 of 7

On 5 Jan., 10:41, "Markus " <ba...@acin.tuwien.ac.at> wrote:
> I like to run the following lines of code
>
> syms theta alpha x y
> alpha = atan2(y,x)
> subs(theta, {x y}, {pi/4 pi/4})
> theta = diff(alpha, x);
>
> But I am getting an error on the second line:
> ??? Undefined function or method 'atan2' for input arguments of type 'sym'.
> Any Ideas how to solve this problem?
>
> Thanks
> Markus
>
> PS.: Substituing atan2 with 2*atan( (sqrt(x^2+y^2)-x)/y) will give me trubles on y == 0 so I dont want to do that.

http://www.mathworks.com/matlabcentral/newsreader/view_thread/73889

Best wishes
Torsten.

Subject: Undefined function or method 'atan2' for input arguments of type

From: Nasser M. Abbasi

Date: 5 Jan, 2012 10:14:51

Message: 3 of 7

On 1/5/2012 3:41 AM, Markus wrote:
> I like to run the following lines of code
>
> syms theta alpha x y
> alpha = atan2(y,x)

> But I am getting an error on the second line:
> ??? Undefined function or method 'atan2' for input arguments of type 'sym'.
> Any Ideas how to solve this problem?
>

But x and y are just symbols at the point atan2 is called.

In other words, they have no numerical values. x and y are just _symbols_

So, I am just curious what do you expect atan2 (if it works for symbols)
to do with them in order to return the correct arctan?

--Nasser

Subject: Undefined function or method 'atan2' for input arguments of type

From: Markus

Date: 5 Jan, 2012 10:55:09

Message: 4 of 7

"Nasser M. Abbasi" <nma@12000.org> wrote in message <je3t6r$mct$1@speranza.aioe.org>...
> On 1/5/2012 3:41 AM, Markus wrote:
> > I like to run the following lines of code
> >
> > syms theta alpha x y
> > alpha = atan2(y,x)
>
> > But I am getting an error on the second line:
> > ??? Undefined function or method 'atan2' for input arguments of type 'sym'.
> > Any Ideas how to solve this problem?
> >
>
> But x and y are just symbols at the point atan2 is called.
>
> In other words, they have no numerical values. x and y are just _symbols_
>
> So, I am just curious what do you expect atan2 (if it works for symbols)
> to do with them in order to return the correct arctan?
>
> --Nasser

Hi

I just want to evaluate a function later or to build the derivative like I did with:

syms theta alpha x y
alpha = atan(y/x)
subs(alpha, {x y}, {pi/4 pi/4})
theta = diff(alpha,x)

Subject: Undefined function or method 'atan2' for input arguments of type

From: Bruno Luong

Date: 5 Jan, 2012 11:00:09

Message: 5 of 7

FWIW,

atan2(y,x) is

imag(log(x+1i*y))
imag(z) = 0.5*(exp(1i*z)-exp(-1i*z))

Bruno

Subject: Undefined function or method 'atan2' for input arguments of type

From: Nasser M. Abbasi

Date: 5 Jan, 2012 11:07:44

Message: 6 of 7

On 1/5/2012 4:55 AM, Markus wrote:
> "Nasser M. Abbasi"<nma@12000.org> wrote in message<je3t6r$mct$1@speranza.aioe.org>...
>> On 1/5/2012 3:41 AM, Markus wrote:
>>> I like to run the following lines of code
>>>
>>> syms theta alpha x y
>>> alpha = atan2(y,x)
>>
>>> But I am getting an error on the second line:
>>> ??? Undefined function or method 'atan2' for input arguments of type 'sym'.
>>> Any Ideas how to solve this problem?
>>>
>>
>> But x and y are just symbols at the point atan2 is called.
>>
>> In other words, they have no numerical values. x and y are just _symbols_
>>
>> So, I am just curious what do you expect atan2 (if it works for symbols)
>> to do with them in order to return the correct arctan?
>>
>> --Nasser
>

> Hi
>
> I just want to evaluate a function later or to build the derivative like I did with:
>
> syms theta alpha x y
> alpha = atan(y/x)
> subs(alpha, {x y}, {pi/4 pi/4})
> theta = diff(alpha,x)

But the above, if it works, can't be really right.

Once you plug in values for x,y in your alpha (after the subs),
then you would no longer be able to differentiate the resulting expression
because it would not long have an 'x' or a 'y' symbols in it. So what would
the diff do then? there is no 'x' any where to be seen.

may be you want this:

------------------------------
syms theta alpha x y
alpha = diff(atan(y/x),x)
------------------------------
alpha =
-y/(x^2*(y^2/x^2 + 1))

No do
----------------------------------
subs(alpha, {x y}, {pi/4 pi/4})
------------------------------

ans =
    -0.6366

--Nasser

Subject: Undefined function or method 'atan2' for input arguments of type 'sym'

From: Roger Stafford

Date: 6 Jan, 2012 03:29:08

Message: 7 of 7

"Markus " <bader@acin.tuwien.ac.at> wrote in message <je3r7k$if3$1@newscl01ah.mathworks.com>...
> PS.: Substituing atan2 with 2*atan( (sqrt(x^2+y^2)-x)/y) will give me trubles on y == 0 so I dont want to do that.
- - - - - - - - -
  It is mathematically equivalent to use 2*atan(y/(sqrt(x^2+y^2)+x)) instead of 2*atan((sqrt(x^2+y^2)-x)/y), which you can see by rationalizing the numerator of this latter expression. In this form there will be no trouble with y equal to zero unless x is negative at the same time, and this occurs along the half-line on which atan2(y,x) itself encounters its discontinuous jump across the negative real axis and therefore gives possible trouble. Across the positive real-axis the expression is well-behaved.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us