Integrating mnvpdf using integral2

10 次查看(过去 30 天)
Hi,
I have a question about integrating mvnpdf using integral2. I have
myPDF = @(x,y) mvnpdf([x,y],[1,2],[1,0;0,1])
result = integral2(myPDF,-100,100,-100,100);
When I try to run this I get the error:
Error using mvnpdfX
X and MU must have the same number of columns
Thanks for your help...

采纳的回答

Shashank Prasanna
Shashank Prasanna 2013-8-21
From the documentation of intergral2:
The function fun must accept two arrays of the same size and return an array of corresponding values. It must perform element-wise operations
Your function does not do element wise operation. As a workaround you will have to write up a function file where you can check if one of x or y is a single element and replicate it to be a vector of constants.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Adding custom doc 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by