Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Help using "disp"
Date: Fri, 23 Jan 2009 10:09:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 40
Message-ID: <glc4vu$kgk$1@fred.mathworks.com>
References: <glc2bi$3ee$1@fred.mathworks.com> <glc2ms$pgd$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1232705342 21012 172.30.248.35 (23 Jan 2009 10:09:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 23 Jan 2009 10:09:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1654357
Xref: news.mathworks.com comp.soft-sys.matlab:513362


"P" <pyjunk.nospam@shaw.ca> wrote in message <glc2ms$pgd$1@fred.mathworks.com>...
> "Daniel Eliasson" <danielel@kth.se> wrote in message <glc2bi$3ee$1@fred.mathworks.com>...
> > Hello
> > 
> > I have done a calcualtion and I get this
> > 
> > ans=
> > 
> > 11.3
> > 
> > But I want it to say
> > 
> > The answer is: 11.3
> > 
> > How do I do that with the disp function?
> > 
> > Thanks
> 
> I come from a C background so I always do this
> 
> 
> ans = 11.3;
> fprintf('The answer is: %3.1f\n', ans);


Thanks, but sometimes it gives "The answer is: 0.0" even if its not 0
my example:

I write this
UtBrd=Bredning*InBrd
fprintf('Wu width: %3.1f\n', UtBrd);

and this happens
UtBrd=
0.0309

Wu Width: 0.0

Is there something with the decimals?