关闭特定数字无法按我的需要工作 - 它只是清除它们

Closing specific figures does not work as I need - it just cleares them

我在 Matlab 中有一个 GUI,我可以在其中绘制许多图形,我已经专门为它们命名,现在我正在开发一个删除功能,点击一个连接到该功能的按钮后,我想要数字被关闭(不仅被清除,而且被关闭),但它反而清除了它们。

代码如下:

if exist('Vectorcardiogram')
close('Vectorcardiogram')
return
end

if exist('Planes')
close('Planes')
return
end

if exist('P wave')
close('P wave')
return
end

if exist('QRS complex')
close('QRS complex')
return
end

if exist('T wave')
close('T wave')
return
end

如您所见,我总共可以绘制 5 个图形,但我不需要总是绘制所有图形,所以这就是我按原样编写代码的原因。

能不能帮帮我,为什么清除指定的图windows而不是关闭它们?

谢谢!

你需要先得到一个handle你的身材:

%Open figure named 'Vectorcardiogram'
figure('Name', 'Vectorcardiogram');

%Return handle to figure named 'Vectorcardiogram'.
h = findobj('Name', 'Vectorcardiogram');

%Close figure.
close(h);

更优雅的解决方案是保存图形的句柄,打开它时,然后使用句柄关闭图形。

示例:

Vectorcardiogram_handle = figure('Name', 'Vectorcardiogram');
%...
%...
close(Vectorcardiogram_handle);