Upper script Variable in the text

조회 수: 1 (최근 30일)
Orkun OZENER
Orkun OZENER 2018년 8월 6일
댓글: Orkun OZENER 2018년 8월 7일
Hi,
I have a fit equation like
a*x^b
I am obtaining the coefficients like this
COEFF = coeffvalues(fittedmodel) a=COEFF(1) b=COEFF(2)
And try to write the equation on plot window.But the upper script (^b section) is always failing. Only the minus sign goes to uppersciprt always
Here is the code
txt = ['y=', num2str(a) ,'*x','^', num2str(b)]
text(50,999,txt);
Any Help???

채택된 답변

Stephen23
Stephen23 2018년 8월 6일
편집: Stephen23 2018년 8월 6일
Put curly braces around the part you want to be superscript:
^{...}
The TeX/LaTeX languages use curly braces to group things together. You can learn more here:
Note that sprintf would be neater and more efficient than using concatenation, e.g.:
txt = sprintf('y=%g*x^{%g}',a,b)
  댓글 수: 1
Orkun OZENER
Orkun OZENER 2018년 8월 7일
Thank you indeed. BR Orkun

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by