Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!news.glorb.com!postnews.google.com!y1g2000pra.googlegroups.com!not-for-mail
From: Justus Skorps <jussa@gmx.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Help using "disp"
Date: Fri, 23 Jan 2009 02:14:26 -0800 (PST)
Organization: http://groups.google.com
Lines: 41
Message-ID: <31d4740c-3b25-4ea9-a24a-f266923e2260@y1g2000pra.googlegroups.com>
References: <glc2bi$3ee$1@fred.mathworks.com> <glc2ms$pgd$1@fred.mathworks.com> 
	<glc4vu$kgk$1@fred.mathworks.com>
NNTP-Posting-Host: 130.183.103.97
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
X-Trace: posting.google.com 1232705666 6983 127.0.0.1 (23 Jan 2009 10:14:26 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 23 Jan 2009 10:14:26 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: y1g2000pra.googlegroups.com; posting-host=130.183.103.97; 
	posting-account=rN5EfQoAAAAPqzVWl69MIEgySjgnuTX8
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.14) 
	Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:513364


On 23 Jan., 11:09, "Daniel Eliasson" <danie...@kth.se> wrote:
> "P" <pyjunk.nos...@shaw.ca> wrote in message <glc2ms$pg...@fred.mathworks.com>...
> > "Daniel Eliasson" <danie...@kth.se> wrote in message <glc2bi$3e...@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?

perhaps you should look in matlab help what the fprintf parameters
do...