Integrating over integral error "A and B must be floating point scalars."

1 回表示 (過去 30 日間)
Fabian
Fabian 2013 年 6 月 2 日
コメント済み: Mic 2015 年 8 月 2 日
I have the following problem. I want to integrate over func2 while func2 itself is an integral over func1. The problem is that the boundary of the second integral is the integration parameter of the first one. This is the code:
func1 = @(x) x + 2;
func2 = @(y) integral(func1,0,y);
a = integral(func2,0,1);
Matlab tells me:
"Error using integral (line 86)
A and B must be floating point scalars."
Many thanks in advance for any help

採用された回答

Andrei Bobrov
Andrei Bobrov 2013 年 6 月 2 日
Try
func1 = @(x) x + 2;
func2 = @(y) integral(func1,0,y);
a = integral(func2,0,1,'ArrayValued',true);
  3 件のコメント
Juan
Juan 2013 年 8 月 24 日
Hello, Is there any way to extend this to integral2? As far as I can tell, integral2 doesn't have the 'ArrayValued' option, is there anyway to get around it.
func1 = @(x) x + 2;
func2 = @(y) integral(func1,0,y);
a = integral2(func2,0,1);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by