using num2str to name a graph in plot

31 ビュー (過去 30 日間)
Richard Barkman
Richard Barkman 2014 年 9 月 12 日
コメント済み: Richard Barkman 2014 年 9 月 12 日
Hi, I am trying to use 'disp([num2str(A)])' command to name a graph.
I have a constant 'a' and a power 'n' on the formula: y = a.*x.^n I try to num2str this in my plot with the following syntax:
text(1,1, ['y = ' (num2str(a)) 'x^' (num2str(n)) ])
What happens is that only the first digit of n get raised up. a is 2.0003 and n is 0.49961, i get:
y = 2.0003x^(0) .49961
I only made it look as I want it to when i instead of num2str wrote:
text(1,1, ['y = ' (num2str(a) 'x' '^0^.^4^9^9^6^1']) which... just doesn't make a very good solution.
Thanks in advance!

採用された回答

Robert Cumming
Robert Cumming 2014 年 9 月 12 日
try:
text(1,1, ['y = ' (num2str(a)) 'x^{' (num2str(n)) '}' ] )
  1 件のコメント
Richard Barkman
Richard Barkman 2014 年 9 月 12 日
Worked like a charm, thanks a lot!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by