Filter löschen
Filter löschen

How to Assign an Axes Object to a struct?

4 Ansichten (letzte 30 Tage)
Rightia Rollmann
Rightia Rollmann am 21 Feb. 2017
Bearbeitet: Jan am 22 Feb. 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

Akzeptierte Antwort

Jan
Jan am 22 Feb. 2017
Bearbeitet: Jan am 22 Feb. 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

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by