MATLAB: Do I receive a “Maximum variable size” error when using the CLABEL function in MATLAB 7.0.4 (R14SP2)


When using the CLABEL function in MATLAB 7.0.4 (R14SP2) with an associated contour plot in which X or Y contain large values:
[C,h] = contour(X,Y,Z,v)
I receive the following error
??? Maximum variable size allowed by the program is exceeded.
Warning: Error occurred while evaluating listener callback.
> In specgraph.contourgroup.schema>LdoShortDirtyAction at 250
In clabel at 84
In PlotOrtho5 at 32
??? Error using ==> ctranspose
Out of memory. Type HELP MEMORY for your options.

Best Answer

  • This bug has been fixed in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
    There is a bug in MATLAB 7.0.4 (R14SP2) in the way that the CLABEL function handles contour plots with large X/Y limits. To work around this issue, use the v6 flag in the call to CONTOUR prior to calling CLABEL:
    [C,h] = contour('v6',X,Y,Z,v);
    Alternatively, setting the "XLim" and "YLim" to the reflect the minimum/maximum value of the "X" and "Y" data used in CONTOUR also resolves the issue:
    [C,h] = contour(X,Y,Z,v);
    set(gca,'XLim',[min(X(:)) max(X(:))]);
    set(gca,'YLim',[min(Y(:)) max(Y(:))]);