フィルターのクリア

How to use an integral inside another integral

5 ビュー (過去 30 日間)
may
may 2013 年 9 月 19 日
コメント済み: may 2013 年 9 月 27 日
I have the following code:
function [answer]=find_integral2(z)
F=@(y) find_integral(z-y).*find_integral(y);
answer= integral(F,-Inf,Inf);
end
function [answer]=find_integral(u)
F = @(x)normpdf(x).*normpdf(u./x);
answer= integral(F,-Inf,Inf);
end
When I call the function find_integral2(4), I get the following error:
Error using ./ Matrix dimensions must agree.
I know I can solve this with triple integral but I want to call find_integral2 several times, i.e. , I want to again use it in another function:
F=@(y) find_integral(z-y).*find_integral2(y);answer= integral(F,-Inf,Inf);
I would appreciate if you could help me fix this error. Thank you.

採用された回答

Mike Hosea
Mike Hosea 2013 年 9 月 23 日
Either this (find_integral is unchanged)
function [answer]=find_integral2(z)
F=@(y) arrayfun(@(y)find_integral(z-y).*find_integral(y),y);
answer= integral(F,-Inf,Inf);
end
or this
function [answer]=find_integral2(z)
F=@(y) find_integral(z-y).*find_integral(y);
answer= integral(F,-Inf,Inf,'ArrayValued',true);
end
  4 件のコメント
may
may 2013 年 9 月 24 日
Thank you SO MUCH! using 'AbsTol',1e-5,'RelTol',1e-3, now it takes around 1 minute!
may
may 2013 年 9 月 27 日
編集済み: may 2013 年 9 月 27 日
Thanks a lot for your help again. so now using 'AbsTol',1e-5,'RelTol',1e-3, I could speed up the function find_integral3(z) (mentioned above), but now I want to again use it to calculate the following integral (this is actually the final problem I want to solve)
F = @(y)find_integral3(z)(z-y).*find_integral3(y);
answer= integral(F,-Inf,Inf,'AbsTol',1e-5,'RelTol',1e-3);
Even after around 8 hours, it did not terminate! I would appreciate if you could help me again.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTime Series Objects についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by