Functions xput, yput, and zput return the respective x, y, or z coordinate of a given fraction of the full x, y, or z range of a plot. These are useful if you have several plots with different data ranges, but you want text or a marker to appear in the same position relative to the frame of each plot. Input argument is simply the fractional linear dimension from 0 to 1.
x = -40:120;
y = x + 10*sin(x);
plot(x,y); hold on
text(xput(.1),yput(.9),'this is an example','fontsize',14)
Jan, that's a great suggestion! I was not aware of the normalized units option. You're right, it's a much better solution than the functions here. Thanks for the tip!
I suggest 'normalized' units for TEXT():
text(0.6, 0.25,'another example!','fontsize',16, 'Units', 'normalized')
Then even zooming does not change the position, e.g. when the resolution is changed temporarily for printing.
But for PLOT() this suggestion will not work. There are good reasons not to use units other than 'data' for line plots.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.