Integral returning infinity for a definite integral with a finite value

1 view (last 30 days)
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

Answers (1)

Star Strider
Star Strider 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

Categories

Find more on External Language Interfaces in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!