Reset figures within ui figure retaining set up

조회 수: 7 (최근 30일)
Katherine
Katherine 2023년 11월 9일
답변: Yash 2023년 11월 14일
I have a code that generates a uifigure. Then it populates this figure with graphs, table and a map. I then run a function and it populates these figures, graphs map etc.
I want to create some code to check if the figures, graphs map etc. have been populated and if so clear then to run other functions, without having to reset up the ui figure

답변 (1개)

Yash
Yash 2023년 11월 14일
Hi Katherine,
I understand that you're interested in verifying whether a uifigure is populated or not and, if so, you'd like to remove the graphs for subsequent functions. To accomplish this, you can make use of the "Children" property of the uifigure. Please refer to the example below, which checks for the presence of a graph on the uifigure:
% Create a uifigure
fig = uifigure;
% Populate a graph onto the figure
ax = uiaxes(fig);
x = 0:0.01:2*pi;
plot(ax,x,sin(x));
% Check for the Children
fig.Children
% You can put a check on the length for the if condition
length(fig.Children)
% Clear / remove the Children
delete(fig.Children)
% Check for the Children
fig.Children
length(fig.Children)
If you are specifically interested in checking whether the graph is populated or not, you can examine the "Children" property of the axes as well:
ax.Children
Hope this information helps you address the issue.

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by