hold on使当前轴及图形保持而不被刷新,准备接受此后将绘制的图形,多图共存
hold off使当前轴及图形不在具备被刷新的性质,新图出现时,取消原图
hold on 在当前图的轴(坐标系)中画了一幅图,再画另一幅图时,原来的图还在,与新图共存,都看得到close allx=0:2:100;
y1=2*x;
y2=3*x;
y3=3.5*x;
ph1=plot(x,y1,'r-'); hold on
ph2=plot(x,y2,'g--');
ph3=plot(x,y3,'b:');
title('fake data')
xlabel('my x data');
ylabel('my y data');
th1=text(x(13),y1(13),'red line');
th2=text(x(15),y2(15),'green line');
th3=text(x(17),y3(17),'blue line');
set(th1,'Color','r');
set(th2,'Color','g');
set(th3,'Color','b')
lh=legend([ph1 ph2 ph3],{'x2';'x3';'x3.5'})
hold off 在当前图的轴(坐标系)中画了一幅图,此时,状态是holdoff,则再画另一幅图时,原来的图就看不到了,在轴上绘制的是新图,原图被替换了close all
x=0:2:100;
y1=2*x;
y2=3*x;
y3=3.5*x;
ph1=plot(x,y1,'r-'); hold off
ph2=plot(x,y2,'g--');
ph3=plot(x,y3,'b:');
title('fake data')
xlabel('my x data');
ylabel('my y data');
th1=text(x(13),y1(13),'red line');
th2=text(x(15),y2(15),'green line');
th3=text(x(17),y3(17),'blue line');
set(th1,'Color','r');
set(th2,'Color','g');
set(th3,'Color','b')
lh=legend([ph1 ph2 ph3],{'x2';'x3';'x3.5'})