MATLAB: Do I receive an error when I specify the “String” property when calling the TITLE function in MATLAB 7.0 (R14)

MATLABpropertystringtitle

I use the following code to create a title for my current axes:
plot(1:10);
title(gca,'string','hello','fontsize',10)
However, when I execute the above code, I receive the following error:
??? Error using ==> title
Incorrect number of input arguments

Best Answer

Documentation on the TITLE function is incomplete in MATLAB 7.0 (R14) or may be misleading.
When using the TITLE function, the string of your title should be specified as part of the input into the function, not as a value for the "String" property. In MATLAB 7.0 (R14), a new addition to the TITLE function allows you to specify the axes handle for your title.
The following function syntax
title(gca,'string','hello','fontsize',10)
throws an error because after the first input which is the axes handle, the function expects a title string and not a property name. The following
syntax would successfully place a title on the current axes in MATLAB 7.0 (R14):
title(gca,'hello','fontsize',10)