From: "Steven_Lord" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Putting text containing variables into plot
Date: Wed, 24 Apr 2013 17:10:42 -0400
Organization: MathWorks
Lines: 38
Message-ID: <kl9hoi$rt9$>
References: <kl98f9$qkq$>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Trace: 1366837842 28585 (24 Apr 2013 21:10:42 GMT)
NNTP-Posting-Date: Wed, 24 Apr 2013 21:10:42 +0000 (UTC)
In-Reply-To: <kl98f9$qkq$>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: comp.soft-sys.matlab:794282

"Kian " <> wrote in message 
> How can I put a text into my plot which passes computed values in there?
> For instance, I have computed my parameters to be:
> pars =
>    0.0005    42.1963
> Now I want to put a text in an appropriate position in my plot (where it 
> does not block the figure content), and pass pars(1) and pars(2) in there.
> My formula is omega(d) = exp(-pars(1)*d^pars(2))
> So, I want to have Matlab to put that for me in the plot as:
> omega(d) = exp(-0.0005*d^pars(2))
> I have already tried to put it in the title by:
> title([ '\omega(d)=exp (' , num2str(pars(1),'%4.5f') , ' d^' , 
> (num2str(pars(2))), ')' ])
> But still, the problem is pars(2) is not completely powered, and only its 
> first digit (4) is powered.

Yes. You will need to group the string representation of the number in curly 
braces in order for TeX to treat it all as the text that should be included 
in the superscript. Compare:

title('x^{17} and y^17')

Steve Lord
To contact Technical Support use the Contact Us link on