图形对象的父级在parfor中无法读取
Afficher commentaires plus anciens
在parfor中,我无法通过 h.Parent() 的方式读取到图形对象的父对象,使用 ancestor(h, "Figure") 方法同样不行,这是为什么?
H = gobjects(3, 1);
figure("Name", "fig1", Visible="off"), H(1) = axes(); plot(1:10);
figure("Name", "fig2", Visible="off"), H(2) = axes(); plot(1:10);
figure("Name", "fig3", Visible="off"), H(3) = axes(); plot(1:10);
% for-loop
for i = 1:3
disp(class(H(i))); % matlab.graphics.axis.Axes
disp(class(H(i).Parent)); % matlab.ui.Figure
disp(class(ancestor(H(i), "figure"))); % matlab.ui.Figure
disp(H(i).Parent.Name); % Fig i
end
% parfor-loop
parfor i = 1:3
disp(class(H(i))); % matlab.graphics.axis.Axes
disp(class(H(i).Parent)); % matlab.graphics.GraphicsPlaceholder, why?
disp(class(ancestor(H(i), "figure"))); % double, why?
disp(H(i).Parent.Name); % error
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 图形对象的标识 dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!