I wonder what is the difference between annotation() and text() in Matlab? In which cases is one of them preferable to the other?
annotation()
text()
Thank you and welcome!
TEXT places the text relative to the axes. In contrast, ANNOTATION position is associated with numbers. ANNOTATION can put a number not only on text, but on lines, shapes, arrows, etc. Therefore, TEXT accepts axes as an argument (or gca for current axes), and ANNOTATION accepts curly pens (or gcf for current figure).
Also note that they create different objects with different properties. For example, if TEXT objects can be rotated using the ROTATION property, ANNOTATION objects do not have this property and cannot be rotated.