Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matlab inline function with argument conditions

Tags:

inline

matlab

folks,

I am wondering if it is possible to write the following function of r as an inline function in matlab. I tried to include the condition as a separate factor such as *(r>a) and I got NaN due to the division of 1/r^3 when r is 0.

function of r

like image 333
nos Avatar asked Aug 26 '26 19:08

nos


1 Answers

I fould a simple way out. It's basically what Shai and Jigg suggested, i.e. using an extra multiplicative factor of (r>a).

To get rid of NaN, we just need to add eps to the denominator of 1/r3, i.e.

 1/(r+eps)^3 *(r>a)
like image 105
nos Avatar answered Aug 28 '26 10:08

nos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!