Xlabel & Ylabel just in 1 line

조회 수: 13 (최근 30일)
Tiago Dias
Tiago Dias 2018년 10월 18일
댓글: Tiago Dias 2018년 10월 18일
Hi,
My goal is to label Xaxis and Yaxis in just one line rather in two, that is what i get.
my xlabel and ylabel are combined from two sides:
m = 5
Variable = sprintfc('Variable%d',1:m)
Variance = [10 20 30 30 10]'
when i do a plot, it plots normally what I need with my X and Y but in the xlabel part i get a 2 line label:
xlabel( Variable(1) Variance(1));
How can i turn it in only 1 line? I tried with ; in the middle doesnt work, with {} also doesnt work

채택된 답변

Walter Roberson
Walter Roberson 2018년 10월 18일
xlabel( sprintf('%s%d', Variable{1}, Variance(1)) );
Though perhaps you would prefer a space between the %s and %d.
  댓글 수: 5
Walter Roberson
Walter Roberson 2018년 10월 18일
I recommend using %g instead of %d for those cases.
xlabel( sprintf('%s %g', Variable{1}, Variance(1)) );
Tiago Dias
Tiago Dias 2018년 10월 18일
yeah %g, i tried %0.5g as in the example on the sprintf page
Thanks a lot!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Switches and Breakers에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by