Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: how to round to 2 decimal?
Replies: 9   Last Post: Nov 14, 2013 8:24 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Nasser Abbasi

Posts: 5,660
Registered: 2/7/05
Re: how to round to 2 decimal?
Posted: Mar 6, 2013 12:13 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 3/5/2013 7:33 AM, chabdullahsaleem@gmail.com wrote:
> On Tuesday, March 4, 2008 8:23:02 PM UTC+5, Deo wrote:
>> hey, how can I set my matlab program to round all the
>> double numbers to 2 decimals

> LET TAKE A SIMPLE EXAMPLE
> x=pi;
> sprintf('%.2f',x)
>
> now type this code in your m file and run it your output will be:
>
> x
>
> 3.14
>



But this does not round x to 2 decimal places.

x does not change in any way after this call.

--Nasser




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.