MATLAB Answers

Copy XLabel from axes: R2014a

4 ビュー (過去 30 日間)
Pankaj
Pankaj 2016 年 10 月 6 日
コメント済み: Pankaj 2016 年 10 月 9 日
Hello
I was trying to copy xlabel text from one axes to another with following code. What I exactly want is XLabel of a1f1 and a1f2 same.
f1 = figure;
a1f1 = axes;
XLa1f1 = xlabel('XLabel of axes');
f2 = figure;
a1f2 = axes;
set(a1f2, 'XLabel', XLa1f1)
The above code produces following error:
Error using set
XLabel must be an existing text child of axes
Can someone tell me how to work around this.
I am using R2014a
Thanks

採用された回答

Wayne King
Wayne King 2016 年 10 月 6 日
編集済み: Wayne King 2016 年 10 月 6 日
You should say what version of MATLAB you are using because handle graphics changed appreciably in 14b.
R2014b and on
f1 = figure;
a1f1 = axes;
XLa1f1 = xlabel('XLabel of axes');
f2 = figure;
ax = gca;
ax.XLabel.String = XLa1f1.String;
Prior to 14b:
f1 = figure;
a1f1 = axes;
XLa1f1 = xlabel('XLabel of axes');
f2 = figure;
xlab = get(XLa1f1,'String');
xlabel(xlab)
  4 件のコメント
Pankaj
Pankaj 2016 年 10 月 9 日
Accepted. Usually I gave sufficient time to others also for answering.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by