How to use mesh() to draw gaussians in 2d, inside this Matlab function…
function G(Mean,Cov,c)
icov = inv(Cov);
det_cov = det(Cov);
const = 1/(2*pi*sqrt(det_cov));
xx = linspace(Mean(1)-3*sqrt(Cov(1,1)),Mean(1)+3*sqrt(Cov(1,1)));
yy = linspace(Mean(2)-3*sqrt(Cov(2,2)),Mean(2)+3*sqrt(Cov(2,2)));
[x y] = meshgrid(xx,yy);
mx=x-Mean(1);
my = y-Mean(2);
z=const*exp(-0.5*(icov(1,1)*mx.^2+icov(2,1)*mx.*my +icov(2,1)*my.*mx+icov(2,2)*my.^2));
contour(x,y,z,c);
Simply replace
contourwithmesh.Also, try not to use
MeanandCovas variable names.meanandcovare Matlab functions, and while the spelling is slightly different, you’re still setting yourself up for some hard-to-find bugs.