Effacer les filtres
Effacer les filtres

How to Assign an Axes Object to a struct?

4 vues (au cours des 30 derniers jours)
Rightia Rollmann
Rightia Rollmann le 21 Fév 2017
Modifié(e) : Jan le 22 Fév 2017
It seems that MATLAB automatically assign h2Axes to struct G, not hAxes. How can I specifically assign hAxes to struct G?
hAxes = axes('NextPlot', 'add', 'XLim', [0, 20], 'YLim', [-1, 10], 'Position', [0 0 0.5 0.5]);
h2Axes = axes('NextPlot', 'add', 'XLim', [0, 20], 'YLim', [-1, 10], 'Position', [0.5 0.5 0.5 0.5]);
W = 4;
Y = 0;
H = 8;
for i = 1 : 3
X = i.* W;
R = rectangle;
R.Position = [X Y W H];
G(i).r = R;
end

Réponse acceptée

Jan
Jan le 22 Fév 2017
Modifié(e) : Jan le 22 Fév 2017
hAxes = axes('NextPlot', 'add', 'XLim', [0, 20], 'YLim', [-1, 10], 'Position', [0 0 0.5 0.5]);
h2Axes = axes('NextPlot', 'add', 'XLim', [0, 20], 'YLim', [-1, 10], 'Position', [0.5 0.5 0.5 0.5]);
W = 4;
Y = 0;
H = 8;
for i = 1 : 3
X = i.* W;
R = rectangle('Parent', hAxes);
% Or:
% R.Parent = hAxes;
R.Position = [X Y W H];
G(i).r = R;
end

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by