Integral returning infinity for a definite integral with a finite value

3 visualizaciones (últimos 30 días)
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

Respuestas (1)

Star Strider
Star Strider el 8 de Dic. de 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

Categorías

Más información sobre External Language Interfaces en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by