我知道这个问题以前是以1D形式提出的(参见quad with mvnpdf involves vector in MATLAB),但我似乎不能用这个来处理2D案例。我想评估一下
integrand = @(x1,x2) mvnpdf([x1,x2],[0,0],[1,0;0,1]);
integral2(integrand,-10,10,-10,10)但是接收错误
X and MU must have the same number of columns.我知道我需要指定integrand函数来执行元素级操作,但是我的尝试是徒劳的。任何帮助都将不胜感激..。
发布于 2014-02-28 10:41:53
尝试以下几点:
integrand = @(x1, x2) reshape(mvnpdf([x1(:), x2(:)],[0,0],[1,0;0,1]), size(x1));Matlab的integral2文档表明:
所有输入函数都必须接受数组作为输入并按元素操作。函数Z= FUN(X,Y)必须接受相同大小的数组X和Y,并返回相应值的数组。
例如,对于上述情况,integral2将两个14×14个矩阵传递给integrand。x(:)利用integral2传递的矩阵生成一维向量.需要这样做才能为mvnpdf提供两个列向量,就像在本例中所期望的那样。然后,mvnpdf返回一个密度值的列向量,必须对其进行整形(使用reshape),以使维度与integral2期望的方式一致。
https://stackoverflow.com/questions/22085992
复制相似问题