MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: silly question on formatting tables


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 at 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!
>



  • Prev by Date: Re: Strange behaviour of Solve
  • Next by Date: Re: Problem with PlotLegends
  • Previous by thread: silly question on formatting tables
  • Next by thread: Re: silly question on formatting tables