MATLAB Answers

Copy XLabel from axes: R2014a

조회 수: 3(최근 30일)
Pankaj
Pankaj 6 Oct 2016
Commented: Pankaj 9 Oct 2016
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

  댓글 수: 0

로그인 to comment.

채택된 답변

Wayne King
Wayne King 6 Oct 2016
Wayne King 님이 편집함. 6 Oct 2016
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

표시 이전 댓글 수: 1
Pankaj
Pankaj 6 Oct 2016
Thanks, that works.
Wayne King
Wayne King 6 Oct 2016
You should accept the answer if that worked for you.
Pankaj
Pankaj 9 Oct 2016
Accepted. Usually I gave sufficient time to others also for answering.

로그인 to comment.

More Answers (0)

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by