MATLAB Answers

## Integral returning infinity for a definite integral with a finite value

Asked by Jack Joynson

### Jack Joynson (view profile)

on 8 Dec 2018
Latest activity Answered by Star Strider

### Star Strider (view profile)

on 8 Dec 2018
Hi,
I am trying to calculate an integral in a loop however it is just returning infinity for every value; The integral in question is finite - I have tested it in wolfram alpha.
Here is my code:
ytheory = 1:10;
s = 14;
func = @(L) s.^(-0.3) .* L.^(-0.7) .*exp(-L./s);
for(i = 1:10)
ytheory(i) = integral(func,0,i);
end
Is this an issue with Matlab or am I doing something wrong here?
Cheers

#### 0 Comments

Sign in to comment.

## 1 Answer ### Star Strider (view profile)

Answer by Star Strider

### Star Strider (view profile)

on 8 Dec 2018

I can’t reproduce that in R2018b.
Your code works as expected:
s = 14;
func = @(L) s.^(-0.3) .* L.^(-0.7) .*exp(-L./s);
for i = 1:10
ytheory(i) = integral(func,0,i);
end
producing:
ytheory =
1.4858 1.8004 2.0019 2.1496 2.2646 2.3576 2.4346 2.4994 2.5547 2.6023

#### 0 Comments

Sign in to comment.