MATLAB: Does MATLAB 7.5 (R2007b) open two figure windows when only one is expected

duplicateextraMATLAB

I execute the following FIGURE command and two figures are opened.
figure('Colormap',jet);
I expect to see only one figure window, since the FIGURE command is only called once.

Best Answer

When the JET function is called inside the FIGURE command, it will create a new figure if no figure is already open. This results in having two figure windows, the first one created by JET, and the second one by FIGURE.
To work around this issue you can divide the command in two separate parts:
figure;
colormap(jet);
Note that the same issue could arise if there existed open figures, but their 'HandleVisibility' was set to 'off'.