One way to do this is to use "<https://www.mathworks.com/help/matlab/ref/annotation.html annotation>" command. The bare-bones syntax for this is as follows:
annotation('textbox', [0.5, 0.2, 0.1, 0.1], 'String', "hi")
This places a text box with horizontal offset of 50% of the Figure's width, and vertical offset of 20% of the Figure's height. The size of the box is 10% of Figure's height by 10% of Figure's width:
To place a textbox outside the plot, you can modify the position and/or dimensions of the axis. For example:
figure;
plot(1:10);
a = gca;
a.Position(3) = 0.6;
annotation('textbox', [0.75, 0.1, 0.1, 0.1], 'String', "pi value is " + pi)
This will produce the following figure: