using num2str to name a graph in plot

조회 수: 35 (최근 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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by