调用该函数时,字符(ch)作为第一个参数,两个正整数表示要绘制的框的宽度和高度。它会自动使用指定的宽度和高度绘制一个带有字符(ch)的框。enter image description here
答案 0 :(得分:0)
检查是否有效:
function drawBox(str,w,h)
ch = [0. 0.] ;
%% get four corners of box
N = 20 ;
x = linspace(ch(1),ch(1)+w,N) ;
y = linspace(ch(2),ch(2)+h,N) ;
[X,Y] = meshgrid(x,y) ;
X(2:end-1,2:end-1) = NaN ;
Y(2:end-1,2:end-1) = NaN ;
x = X(~isnan(X)) ;y = Y(~isnan(Y)) ;
plot(x,y,'.w') ; hold on
text(x,y,str)
axis off