MATLAB: Does the CONTOURF function permit only two output arguments instead of three

7argumentsassignedcontourfMATLABnotr14three

In MATLAB 7.0 (R14), the CONTOURF function no longer seems to work with three output arguments specified. For example, the following code:
[C,h,Cf]=contourf(peaks);
produces the following error:
??? One or more output arguments not assigned...
The documentation on CONTOURF indicates that three output arguments can be specified.

Best Answer

This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
We have verified that there is a bug in MATLAB 7.0 (R14) in the way that the CONTOURF handles three output arguments.
To work around this issue:
1) Open contourf.m using the following command in the MATLAB Command Window:
edit contourf
2) Save a backup of the function as 'countourf.old' and close it.
3) Reopen contourf.m using:
edit contourf
4) Change the first line of the file to:
function [cout,hand,cf] = contourf(varargin)
5) Save the file.
The CONTOURF function should now behave as described in the documentation.