Double integral where the limit of y is a function of x

1 回表示 (過去 30 日間)
Wenjuan
Wenjuan 2013 年 12 月 10 日
コメント済み: Andrei Bobrov 2013 年 12 月 11 日
I am trying to work out double integral, where the limit of y is a function of x, and the limits itself are vectors, like
n=1:10;
t=2;
a=(n-1).*t;
b=n.*t;
fun=@(x,y)lognpdf(b-x,2,1).*lognpdf(y,3,2);
ymax=@(x) b-x;
Qab=@(a,b)integral2(fun,a,b,0,ymax);
Q=arrayfun(Qab,a,b);
but this returns error
Error using -
Matrix dimensions must agree.
Error in @(x)b-x
Is this because b is a vector?
  1 件のコメント
Walter Roberson
Walter Roberson 2013 年 12 月 10 日
Perhaps you should use the ArrayValued option of integral2() ?

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

回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2013 年 12 月 10 日
編集済み: Andrei Bobrov 2013 年 12 月 11 日
EDIT
n=1:10;
t=2;
a=(n-1).*t;
b=n.*t;
[ai,y] = ndgrid(a,b);
bi = y.';
f = @(x,y,y2)logpdf(y2-x,2,1).*logpdf(y,3,2);
out = arrayfun(@(x1,y1,y2)integral2(@(x,y)f(x,y,y2),x1,y1,0,@(x)y2-x),ai,bi,y);

カテゴリ

Help Center および File ExchangeCircuits and Systems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by