I would like to set up a property as an equation. This could apply to a figure, axis, etc. property, but I am specifically interested my making my annotation positions dynamic with variables, so that if I used commands like 'xlim' or 'axis equal' after I place the annotations, the annotation locations move appropriately. I used this guide to properly place my annotation on the figure, but when I use commands like 'xlim' or 'axis equal' later in my script, the annotations stay in the original positions in my figure window and don't track with where they should be like in the plot domain. I though maybe I could make the Position elements variable like this:
h_ann = annotation('textbox',[0.5 0.5 0.1 0.1 ],'String','my annotation');
a = 0.2;
b = 0.3;
but the 'set' command throws the error:
Error using handle.handle/set
Invalid or deleted object.
Is there a way to do this so that later in my program, if I update a or b, my annotation location would updated? I realize that I could directly change h_ann with set later in the program, but this would be messy.
Here is an example where I initially place an annotation...
then change some axis properties and the annotation is no longer where I want it...
The position in the figure window is maintained, but I'd like to link the position to axis properties.