MathGroup Archive 2012

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

Search the Archive

Re: silly question on formatting tables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129114] Re: silly question on formatting tables
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Sun, 16 Dec 2012 01:07:53 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <kaem93$5qp$1@smc.vnet.net>

On Dec 13, 11:59 pm, alba.may... 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!

mat = {{0, 0, 1.19092}, {0.883038, 0, 0.366804}, {0, 0, 0}};

Map[NumberForm[#,If[IntegerQ@#,3,{3,2}]]&,mat,{2}] //TableForm

0      0   1.19
0.88   0   0.37
0      0   0



  • Prev by Date: Export graphics without notebook ( using .m file)
  • Next by Date: Do Plot
  • Previous by thread: Re: silly question on formatting tables
  • Next by thread: Re: silly question on formatting tables