在没有关闭功能的情况下删除matlab图形上的补丁
Removing patch on matlab figure without close function
我在matlab图上画了一个正方形,如下图
x = [-1 1 1 -1];
y = [-1 -1 1 1];
h=figure(1)
patch(x,y,'red')
axis([-2 2 -2 2])
结果如下
我想在不使用matlab close函数的情况下擦除红色方块,如下所示。
如何在不关闭数字的情况下擦除正方形?
提前致谢。
指定输出到 patch
not only allows you to access and modify the object's properties, it also allows you to pass it to other functions. In this case, you can pass the object to the delete
函数,这将从内存中清除它。
例如:
x = [-1 1 1 -1];
y = [-1 -1 1 1];
h = figure(1);
p = patch(x, y, 'red');
axis([-2 2 -2 2]);
pause(0.5); % Wait half a second
delete(p)
请注意,虽然 delete
从内存中清除引用的对象,但不会从工作区中清除变量。如有必要,您可以使用 clear
进行管理。
我在matlab图上画了一个正方形,如下图
x = [-1 1 1 -1];
y = [-1 -1 1 1];
h=figure(1)
patch(x,y,'red')
axis([-2 2 -2 2])
结果如下
我想在不使用matlab close函数的情况下擦除红色方块,如下所示。
如何在不关闭数字的情况下擦除正方形?
提前致谢。
指定输出到 patch
not only allows you to access and modify the object's properties, it also allows you to pass it to other functions. In this case, you can pass the object to the delete
函数,这将从内存中清除它。
例如:
x = [-1 1 1 -1];
y = [-1 -1 1 1];
h = figure(1);
p = patch(x, y, 'red');
axis([-2 2 -2 2]);
pause(0.5); % Wait half a second
delete(p)
请注意,虽然 delete
从内存中清除引用的对象,但不会从工作区中清除变量。如有必要,您可以使用 clear
进行管理。