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.math.mathematica

Topic: silly question on formatting tables
Replies: 4   Last Post: Dec 18, 2012 2:34 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
James Stein

Posts: 130
Registered: 5/8/10
Re: silly question on formatting tables
Posted: Dec 15, 2012 5:48 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Here's one way:

ClearAll [ f ] ;
SetAttributes [ f , Listable ] ;
f [ x_ ] := Switch [ Head [ x ] ,
Real, Round [ x , .01 ] , _ , x ] ;
{{0, 0, 1.19092}, {0.883038, 0, 0.366804}, {0, 0, 0}} //
f // MatrixForm


On Fri, Dec 14, 2012 at 12:01 AM, <alba.maydeu@gmail.com> wrote:
> Dear all,
>
> Consider the matrix
>
> {{0, 0, 1.19092}, {0.883038, 0, 0.366804}, {0, 0, 0}}
>
> How can I display it in matrixform/tableform so that the integers are displayed as integers and the reals are displayed only with 2 decimals?
>
> If I use MatrixForm, the reals are displayed with 6 decimals, and if I use TableForm all numbers, including integers are displayed with 2 decimals.
>
> Thanks!
>





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.