I've used the gmdistribution
to fit data to a Gaussian mixture model. I wanted to plot a contour plot https://i.stack.imgur.com/d6Pdb.jpg where the contours are obviously missing. For a 1D problem I found fplot
, but now I'm stumped.
Asked
Active
Viewed 2,174 times
3

Amro
- 123,847
- 25
- 243
- 454

Piotr Sokol
- 245
- 1
- 13
1 Answers
2
I ran into a similar problem when I wrote an EM algorithm for gaussian mixtures. Here is the snippet of code that fixed it in my case:
for l=1:k
zz=gmdistribution(MU(l,:),SIG(:,:,l),PI(l));
ezcontour(@(x,y)pdf(zz,[x y]),[minx1 maxx1],[miny1 maxy1],250);
end
The key is to increase N
:
ezcontour(...,N) plots FUN over the default domain using an N-by-N
grid. The default value for N is 60.

AGS
- 14,288
- 5
- 52
- 67
-
Ok, I tested for too low values of grid elements; e.g. >100. I see now that >250 is optimal. Thanks. – Piotr Sokol Aug 25 '12 at 23:21