Problem using dblquad
Ältere Kommentare anzeigen
Hi everyone, I'm trying to use the function dblquad but I'm having some problems. This is my code:
mu = [2,1];
sigma = [0.2,0;0,0.1];
df=@(x1,x2)mvnpdf([x1,x2],mu,sigma);
Q = dblquad(df, 0, 2, 0, 1)
And Matlab throws me the error: X and mu must have the same number of columns, where X is the first input of the mvnpdf function. Anyone can help me? Regards!
Antworten (1)
Walter Roberson
am 9 Mär. 2012
fun(x,y) must accept a vector x and a scalar y and return a vector of values of the integrand.
You do not know ahead of time how long the vector x is going to be, and there is no explicit statement about whether it is a row vector or a column vector. [x,y] might break on incompatible dimensions or it might not -- but [x,y] is very unlikely to be the same size as your mu.
Possible workaround:
df = @(x,y) arrayfun( @(x1,y) mvnpdf([x1,y],mu,sigma), x );
1 Kommentar
ignacio rios
am 12 Sep. 2012
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!