Filter löschen
Filter löschen

Upper script Variable in the text

1 Ansicht (letzte 30 Tage)
Orkun OZENER
Orkun OZENER am 6 Aug. 2018
Kommentiert: Orkun OZENER am 7 Aug. 2018
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???

Akzeptierte Antwort

Stephen23
Stephen23 am 6 Aug. 2018
Bearbeitet: Stephen23 am 6 Aug. 2018
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)

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion 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