cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

writing a program

YA_10963798
14-Alexandrite

writing a program

 

 

I'm trying to write this expression in mathcad to get the same results which I have in Excel 

However, I'm getting that wrong answers, can you please help me

 

 

 

YA_10963798_0-1716896052821.pngYA_10963798_1-1716897189128.png

YA_10963798_2-1716897259800.png

 

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:Werner_E)

Maybe you can make use of this Atan2 function which returns angles in the range from -pi/2 to 3 pi /2 which seems to be  what you want.

Werner_E_1-1716902671668.png

 

 

View solution in original post

5 REPLIES 5
Werner_E
25-Diamond I
(To:YA_10963798)

In Prime atan2 returns angles in the range from -180 degree to 180 degree.

So you get -135° instead of 225°. Both angles are equivalent, their difference is 360°.

BTW, the ARCTAN2 (ATAN2) function in Excel shows the very same behaviour and returns angles in the range of -pi to pi.

Werner_E_0-1716901226507.png

So as you show a value of 225 in your picture, a different formula seems to have been used in Excel to get that value.

One way I could imagine is that arctan(x/y) is used and if x<0 then pi (180°) is added to the result. This will result in returning angles in the range from -90° to 270°.

 

In the picture you show the normal arctan function is used. This function by default only returns angles in the range from -pi/2 (-90°) to pi/2 (+90°), so you never would get neither -135° nor 225° but just +45°.

YA_10963798
14-Alexandrite
(To:Werner_E)

I have to get 225 . the same results in Excel , because I will use this number again in different equation. 

how to  add an if statement?

Thanks in advance 

Werner_E
25-Diamond I
(To:YA_10963798)


@YA_10963798 wrote:

I have to get 225 . the same results in Excel , because I will use this number again in different equation. 

how to  add an if statement?

Thanks in advance 


If you want the same results as in Excel, you have to use the same formula as in Excel. We don't know which formula that is but is sure not the one you showed in the picture, because the arctan function will only return values from -90 to +90.

 

Adding an if-statement means programming:

About Programs

Using Conditional Statements

 

If you need help doing so, you would have to post both the Excel sheet as well as your Prime sheet and state which version of Prime you are using.

Werner_E
25-Diamond I
(To:Werner_E)

Maybe you can make use of this Atan2 function which returns angles in the range from -pi/2 to 3 pi /2 which seems to be  what you want.

Werner_E_1-1716902671668.png

 

 

YA_10963798
14-Alexandrite
(To:Werner_E)

I really appreciate your help and taking the time to help . Thank you 

Announcements

Top Tags