Asked by Harsha K
on 15 Aug 2017

Hello,

This is my function definition.

function E_j = E_fld_integ(facet_flag, pd, lower_limit, upper_limit)

F = @(x)(exp(1i*pd).*exp(1i*k*x*sin_theta));

G = @(x)(exp(1i.*(pd + (pd_def_min-sqrt(pd_def_min^2-x.^2)) ) )...

.* exp(1i*k*x.*sin_theta) );

% case 1: E_j = integral(F, lower_limit, upper_limit, 'ArrayValued', true);

% case 2: E_j = integral(G, lower_limit, upper_limit, 'ArrayValued', true);

end

Where F and G are functions of variable 'x'. All other names(k, pd_def_min, pd) are constants. Although 'sin_theta' is a vector with 1000 values.

Let us consider values of constants:

lower_limit = 30000; upper_limit = 50000; pd = 0; pd_def_min = 95;

Goal: I would like the result of the definite integral to be an array of 1000 double-valued complex numbers in both cases above for F and G functions respectively.

Current scenario and problem:

1. F evaluates conveniently with the provided limits.

2. Whereas evaluation of G translates to the following error:

- Warning: Infinite or Not-a-Number value encountered.
- > In integralCalc/iterateArrayValued (line 267)
- In integralCalc/vadapt (line 130)
- In integralCalc (line 75)
- In integral (line 88)
- In [mainfunctioncall]>E_fld_integ (line 206)

Could someone help me understand as to what is happening and is there a more elegant (and fast execution-wise) solution for the above goal?

Do I have to use Taylor's expansion or Bessels integrals to solve for "G" ?

Answer by Harsha K
on 13 Sep 2017

Accepted Answer

Hi all,

I just solved this problem by centering the x-axis in the computational space within the evaluation interval.

As in:

G = @(x)(exp(1i.*(pd + (pd_def_min-sqrt(pd_def_min^2-(x-(lower_limit+upper_limit)/2).^2)) ) )...

.* exp(1i*k*x.*sin_theta) );

Then the problem that Torsten mentioned above vanished.

Sorry for this late reply. All is well that ends well.

Cheers.

Sign in to comment.

Answer by Harsha K
on 15 Aug 2017

Edited by Harsha K
on 15 Aug 2017

Hi all,

By the way, I want to achieve the desired result without using the symbolic toolbox as: firstly I do not have the license for the same; and secondly the evaluation using symbolic really increases my code execution time.

Best,

Harsha

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 4 Comments

## Torsten (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/352795-problem-with-definite-integration-using-integral-infinite-or-not-a-number-value-encountered#comment_477115

## Harsha K (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/352795-problem-with-definite-integration-using-integral-infinite-or-not-a-number-value-encountered#comment_477119

## Torsten (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/352795-problem-with-definite-integration-using-integral-infinite-or-not-a-number-value-encountered#comment_477123

## Harsha K (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/352795-problem-with-definite-integration-using-integral-infinite-or-not-a-number-value-encountered#comment_484007

Sign in to comment.