如何在MATLAB中获取某个图形的最小x、最大x、最小y和最大y?

How to get the min x, max x, min y and max y of a certain figure in MATLAB?

我想设计一个功能,可以根据用户输入的参数在图形右上角添加文字('UpperLeft', 'UpperRight', 'LowerLeft', 'LowerRight').我是这样实现的:如果我想在左上角添加文字,我先得到图中坐标轴的最小x和最大y,然后用text(min_x, max_y, 'text')画出来。但是我不知道什么函数可以得到最小x和最大y。还有其他方法可以实现我想要的功能吗?

x = 3*sin(linspace(0,10,100));
figure
plot(x)
xl = xlim
yl = ylim
% upper left (ish), you'll want to position the text a little down and to
% the right depending on the dimensions of the plot
text(xl(1), yl(2), 'text')