Integral returning infinity for a definite integral with a finite value

3 ビュー (過去 30 日間)
Jack Joynson
Jack Joynson 2018 年 12 月 8 日
回答済み: Star Strider 2018 年 12 月 8 日
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

回答 (1 件)

Star Strider
Star Strider 2018 年 12 月 8 日
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

カテゴリ

Help Center および File ExchangeExternal Language Interfaces についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by