So i have a function which i plot that looks like this
f(x)= (1i*omega*mueh)*(2*d^3/3*1000/(pi*120))*(-(i *(x - x1)* exp(-i* k* sqrt((x - x1)^2 + (y - y1)^2 + (z - z1)^2))* (k* sqrt((x - x1)^2 + (y - y1)^2 + (z - z1)^2) - i))/(4* pi *((x - x1)^2 + (y - y1)^2 + (z - z1)^2)^(3/2)))
It is a function for an the z component of an electric field. I now need the absolut value of that field. Here comes the kicker.
I get two different results. Its different between abs() and doing sqrt(a^2+b^2). So it seems like i dont really know enough about abs() or what it really does. I though i should get the same result. can someone enlighten me so i dont fall for this again?
I Attached my script. There is a lot going on. Its basicly a superpositon of the values.
The important lines are 136 and 138

4 件のコメント

Jan
Jan 2017 年 10 月 25 日
編集済み: Jan 2017 年 10 月 25 日
Please post the used code. "abs()" and "sqrt(a^2+b^2)" leaves open, what is used as argument of abs() and what "a" and "b" is. What exactly is "abs by hand?"
Torsten
Torsten 2017 年 10 月 25 日
Please show the code you are using for the plot.
Best wishes
Torsten.
Walter Roberson
Walter Roberson 2017 年 10 月 25 日
Not is not clear what your a and b are for this purpose?
Patrick Philipiak
Patrick Philipiak 2017 年 10 月 25 日
編集済み: Patrick Philipiak 2017 年 10 月 25 日
Sorry im new to the matlab forum. I attached the script so you can reproduce it now.

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2017 年 10 月 25 日

0 投票

abs gives you a positive value always if you input a number. It gives you sqrt(Real^2+imaginary^2) if you input a a complex number.

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

タグ

質問済み:

2017 年 10 月 25 日

編集済み:

2017 年 10 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by