Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Round down to nearest decimal???
Date: Wed, 30 Mar 2011 01:02:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <imtvec$9pp$1@fred.mathworks.com>
References: <imtsb0$lgp$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-00-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1301446924 10041 172.30.248.45 (30 Mar 2011 01:02:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 30 Mar 2011 01:02:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:718951

"JP" wrote in message <imtsb0$lgp$1@fred.mathworks.com>...
> Hi all,
> 
> I need help with the rounding functions in MATLAB.
> 
> For example if I have a value
>          x = 0.0047;
> 
> and I'd like to round it down to one significant figure. would I be able to do that?
> 
> i.e. round x so that it equals to x = 0.004;
> 
> Please help. Thanks in advance.
> 
> 
> JP
- - - - - - - -
 y = 10^floor(log10(x));
 y =  round(x/y)*y;

Roger Stafford