フィルターのクリア

How to do this double integration using integral2? Thanks!

1 回表示 (過去 30 日間)
Tmat
Tmat 2020 年 3 月 19 日
コメント済み: Ameer Hamza 2020 年 3 月 19 日
Hi, I'm trying to write some code to calculate accumulated the probability of using integral2. Here is my code:
clear;
ae=-4;be=4;
az=-8;bz=8;
fune=@(e)1/(be-ae)*(e>=ae).*(e<=be); % density of e
funz=@(z)1/(bz-az)*(z>=az).*(z<=bz); % density of z
funezt=@(ez,t)fune(ez(:)-t).*funz(t);
funez=@(ez)integral(@(t)funezt(ez,t),az,bz,'ArrayValued',true); % density of ez=e+z computed via convolution
funez12=@(ez1,ez2)funez(ez1).*funez(ez2); % joint density of (ez1,ez2)
aaa=integral2(funez12,0,4,0,4); %double integration on [0,4]^2
However, this code didn't work and has the following error message:
Error using integral2Calc>integral2t/tensor (line 241)
Integrand output size does not match the input size.
Have no clue about how to fix it, and need some insights. Thanks!

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 3 月 19 日
To use a function as input to integral2, the input and output dimension must be the same. However, in your case, if we input a 2x2 matrices to funez12, the output is 4x1. Changing the line like this will correct the error
funez12 = @(ez1,ez2)reshape(funez(ez1).*funez(ez2), size(ez1)); % joint density of (ez1,ez2)
However, the correct solution depends on how you interpret the entries in the matrix.
  2 件のコメント
Tmat
Tmat 2020 年 3 月 19 日
Thanks a lot, Ameer, it worked!
Ameer Hamza
Ameer Hamza 2020 年 3 月 19 日
Glad to be of help.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by