MATLAB: Does the axis title disappear when I use logarithmic plots with a large Y upper limit in MATLAB 7.9 (R2009b)

MATLAB

I am creating a log-log plot using an extremely large upper limit for my Y-axis. When I attempt to display the title, the title does not appear. This is an example of the code:
x = logspace(-3,2,306);
y = (50).^(3.*x);
loglog(x,y);
h = title('title >> \alpha<<\omega');
get(h,'position')

Best Answer

The title position is calculated relative to the axes coordinates. If the upper limit of the Y-axis is too large, the Y-position of the title may be calculated as INF since any floating point value greater than 1.7977e+308 is INF.
To see this, you may play with the REALMAX operator in MATLAB. REALMAX returns the maximum representable floating point (double) value. For example:
realmax
realmax + eps(realmax)
One workaround is to set the Y-position to REALMAX if the title is off the figure. This may be done as follows:
h = title('title >> \alpha<<\omega'); % return the handle to the title in 'h'
pos = get(h,'position') % get the title position. This returns a 3-element vector with the X,Y, and Z coordinates
pos(2) = min(pos(2),realmax) % Set the Y-position to the minimum of REALMAX and the current position