Hi, nice and efficient piece of code.
Nevertheless, I believe that the polynomial expression that you compute in a first step is not guaranteed to be one of an ellipsoid. I think that it could be any quadric (hyperboloid, paraboloid, etc), right?
It is probably no problem if you have much data (corresponding to a real ellipsoid) to fit your quadric on.
But in case of sparse data (for instance, data points only on a couple of planes), you could have bad surprises (and in particular negative eigenvalues).
Thanks for this excellent code. I've used it many times without problems, but just ran into a problem today. I have a colormap with five colors. When I use freezeColors, it does in fact freeze the colors, but it reduces the number of colors from five to four. Any suggestions on how to fix this?
Freezecolor was just what I needed to plot contours over map data and I have used it for a while. However, in MatLab 2012a and later freezing contourm results no longer works without some modification. There is a listener associated with this plot that remaps all the color levels whenever the colormap is changed thereby undoing the freezecolor changes.I solved this problem by switching the parent of all the countour's children from its hggroup typed parent to that of the parent axis. This disassociates the contour from the hggroup listener. This works for my application so far.
Scatterm does not have this listener and freezcolor works great, however, I came across one small error for an unusual case. If there is only one point in the scatter plot (my plots depend on user clicks and sometime degenerate to this point) then the color is of the wrong dimensionallity. The listener in scatterm that is triggered when the color is frozen has code that checks if the first dimension of cdata is 1 then the second dimension must be 3 or it will be ignored - not colored. The structure freezecolor passes in is 1x1x3. I put a check in freezecolor for object types ~patch (scatterm plots are hggroup type) that if size(realcolor,1)==1 then realcolor=squeeze(realcolor)'.