Problem using dblquad
Mostrar comentarios más antiguos
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!
Respuestas (1)
Walter Roberson
el 9 de Mzo. de 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 comentario
ignacio rios
el 12 de Sept. de 2012
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!