MATLAB: Does the SEMILOGY function not plot onto a logarithmic scale in MATLAB 6.5 (R13)

linearlogarithmicMATLABpolarsemilogy

Why does the SEMILOGY function not plot onto a logarithmic scale in MATLAB 6.5 (R13)?
Try the following lines of code:
y = rand(1, 20);
figure
hold
semilogy(1:20, y)
The resulting graph is plotted in a linear fashion and not in semi-log fashion. However, if I rearrange the order of the last two commands, the axes remains semilog.

Best Answer

This is a bug in the documentation in MATLAB R13. This bug was fixed in MATLAB 7.4 (R2007a) to include the following statement in the help for LOGLOG, SEMILOGX/SEMILOGY function:
If you attempt to add a loglog, semilogx, or semilogy graph to a linear axis mode plot with hold on, the axis mode will remain as it is and the new data will plot as linear.
When the figure is created its axes are linear by default and executing a HOLD function after creating the figure locks the properties of the figure and also the axes.
The axes are set to 'log' with SEMILOGY function if it is executed before the HOLD command, therefore, you can use HOLD with SEMILOGY without setting the scale of the y-axis to 'log' as long as you execute SEMILOGY before HOLD, i.e.,
y = rand(1, 20);
figure
semilogy(1:20, y)
hold
Similarly, the POLAR and HOLD functions also behave in the same manner. In this case too, the POLAR function should be executed before the HOLD function to prevent plotting polar data on a linear scale.